Network¶
Arakawa supports Sigma.js & Graphology based network visualization.
Note
- A graph is layout by ForceAtlas2 and you can configure it by
layout_settings
option.layout_settings
option is same as this settings. However, note that the name of each setting is lowercased. - Each node of a graph should have
label
attribute.
Sigma
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict[str, Any]
|
A Sigma/Graphology graph data to attach |
required |
width
|
int
|
A width of the graph |
960
|
height
|
int
|
A height of the graph |
540
|
layout_settings
|
LayoutSettings | None
|
see https://www.npmjs.com/package/graphology-layout-forceatlas2#settings (optional, each key should be snake_cased) |
None
|
name
|
str | None
|
A unique name for the block to reference when adding text or embedding (optional) |
None
|
label
|
str | None
|
A label used when displaying the block (optional) |
None
|
ar.Sigma(
data={
"options": {"type": "mixed", "multi": False, "allowSelfLoops": True},
"attributes": {},
"nodes": [
{
"key": "A",
"attributes": {
"label": "A",
"size": 20,
},
},
{"key": "B", "attributes": {"label": "B", "size": 20}},
],
"edges": [{"key": "geid_179_0", "source": "A", "target": "B"}],
}
)
NetworkX
¶
The NetworkX block allows you to embed an NetworkX graph (rendered by Sigma.js) into your app.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph
|
Graph
|
An NetworkX graph to attach |
required |
width
|
int
|
A width of the graph |
960
|
height
|
int
|
A height of the graph |
540
|
layout_settings
|
LayoutSettings | None
|
see https://www.npmjs.com/package/graphology-layout-forceatlas2#settings (optional, each key should be snake_cased) |
None
|
name
|
str | None
|
A unique name for the block to reference when adding text or embedding (optional) |
None
|
label
|
str | None
|
A label used when displaying the block (optional) |
None
|
import networkx as nx
G = nx.karate_club_graph()
for ix, node in enumerate(list(G.nodes())):
G.nodes[node]["label"] = str(ix)
G.nodes[node]["size"] = G.degree(node)
ar.NetworkX(
G,
layout_settings={
"outbound_attraction_distribution": True,
"barnes_hut_optimize": True,
"adjust_sizes": True,
"lin_log_mode": True,
},
)