UNKNOWN
Project description
========================
Sonnet J(SON + Net)workX
========================
Sonnet wraps a NetworkX graph and produces detailed JSON output for use with JavaScript to produce detailed graph visualizations in the browser.
Getting Started
===============
Install Sonnet::
pip install sonnet
Build a NetworkX graph::
import networkx as nx
g = nx.gnp_random_graph(20, 0.5)
Wrap it with Sonnet::
import sonnet as sn
s = sn.Sonnet(g, name='An Awesome Graph')
Build stats directly into node directory using modified NetworkX algorithms. Currently available: degree, degree_centrality, in_degree_centrality, out_degree_centrality, closeness_centrality, betweenness_centrality, eigenvector_centrality::
s.betweenness_centrality()
Find communities and assign nodes to group based on community::
s.find_communities()
Rank node size by nodes by attribute::
s.rank_nodes(rank_by='betweenness_centrality')
Now we have a nodes with lots of relevant data::
Produce JSON data (example data reduced for readability)::
s.jsonify()
'{
"directed": false,
"name": "An Awesome Graph",
"links": [
{
"source": 4,
"target": 8
},
{
"source": 5,
"target": 7
},
{
"source": 6,
"target": 8
},
],
"multigraph": false,
"graph": [
[
"name",
"gnp_random_graph(10,0.5)"
]
],
"nodes": [
{
"betweenness_centrality_ranking": 2.7258064516129035,
"community": 2,
"id": 0,
"betweenness_centrality": 0.04953703703703703
},
{
"betweenness_centrality_ranking": 1,
"community": 1,
"id": 1,
"betweenness_centrality": 0.0
},
{
"betweenness_centrality_ranking": 4.580645161290322,
"community": 1,
"id": 2,
"betweenness_centrality": 0.10277777777777775
},
{
"betweenness_centrality_ranking": 6.0,
"community": 2,
"id": 3,
"betweenness_centrality": 0.1435185185185185
},
]
}'
D3Graph
=======
D3Graph is designed to produce JSON output for D3.js graphs. It works just like Sonnet, but it has extra attributes set at during init.
Compare::
s = sn.Sonnet(g)
vars(s)
{'color_by': 'community',
'graph': <networkx.classes.graph.Graph at 0x1726210>,
'max_node_size': 6,
'min_node_size': 1,
'name': None,
'rank_by': 'degree_centrality'}
d = ns.D3Graph()
vars(d)
{'charge': -150,
'color_by': 'community',
'graph': <networkx.classes.graph.Graph at 0x1726210>,
'gravity': 0.06,
'height': 800,
'link_distance': 40,
'max_node_size': 6,
'min_node_size': 1,
'name': None,
'rank_by': 'degree_centrality',
'width': 1280}
Sonnet J(SON + Net)workX
========================
Sonnet wraps a NetworkX graph and produces detailed JSON output for use with JavaScript to produce detailed graph visualizations in the browser.
Getting Started
===============
Install Sonnet::
pip install sonnet
Build a NetworkX graph::
import networkx as nx
g = nx.gnp_random_graph(20, 0.5)
Wrap it with Sonnet::
import sonnet as sn
s = sn.Sonnet(g, name='An Awesome Graph')
Build stats directly into node directory using modified NetworkX algorithms. Currently available: degree, degree_centrality, in_degree_centrality, out_degree_centrality, closeness_centrality, betweenness_centrality, eigenvector_centrality::
s.betweenness_centrality()
Find communities and assign nodes to group based on community::
s.find_communities()
Rank node size by nodes by attribute::
s.rank_nodes(rank_by='betweenness_centrality')
Now we have a nodes with lots of relevant data::
Produce JSON data (example data reduced for readability)::
s.jsonify()
'{
"directed": false,
"name": "An Awesome Graph",
"links": [
{
"source": 4,
"target": 8
},
{
"source": 5,
"target": 7
},
{
"source": 6,
"target": 8
},
],
"multigraph": false,
"graph": [
[
"name",
"gnp_random_graph(10,0.5)"
]
],
"nodes": [
{
"betweenness_centrality_ranking": 2.7258064516129035,
"community": 2,
"id": 0,
"betweenness_centrality": 0.04953703703703703
},
{
"betweenness_centrality_ranking": 1,
"community": 1,
"id": 1,
"betweenness_centrality": 0.0
},
{
"betweenness_centrality_ranking": 4.580645161290322,
"community": 1,
"id": 2,
"betweenness_centrality": 0.10277777777777775
},
{
"betweenness_centrality_ranking": 6.0,
"community": 2,
"id": 3,
"betweenness_centrality": 0.1435185185185185
},
]
}'
D3Graph
=======
D3Graph is designed to produce JSON output for D3.js graphs. It works just like Sonnet, but it has extra attributes set at during init.
Compare::
s = sn.Sonnet(g)
vars(s)
{'color_by': 'community',
'graph': <networkx.classes.graph.Graph at 0x1726210>,
'max_node_size': 6,
'min_node_size': 1,
'name': None,
'rank_by': 'degree_centrality'}
d = ns.D3Graph()
vars(d)
{'charge': -150,
'color_by': 'community',
'graph': <networkx.classes.graph.Graph at 0x1726210>,
'gravity': 0.06,
'height': 800,
'link_distance': 40,
'max_node_size': 6,
'min_node_size': 1,
'name': None,
'rank_by': 'degree_centrality',
'width': 1280}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sonnet-0.1.6.tar.gz
(11.0 kB
view details)
File details
Details for the file sonnet-0.1.6.tar.gz
.
File metadata
- Download URL: sonnet-0.1.6.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57de398cff621a66f9d0658a9efe52059cd6ff38dc2e87969d6f365f5fc1ebdf |
|
MD5 | 1c95dbd4a285f6bffdb91ad66c2939f3 |
|
BLAKE2b-256 | 01aa641d5113d301cc67e2efd802bfd566ab5390676ea1117b2b8954ea6d60c1 |