Interactive Graph Vis for Streamlit.
Project description
Based on react-graph-vis
Install
pip install streamlit-agraph
Example App
Check out the example App!
Use
import streamlit
from streamlit_agraph import agraph, Node, Edge, Config
nodes = []
edges = []
nodes.append( Node(id="Spiderman",
label="Peter Parker",
size=25,
shape="circularImage",
image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_spiderman.png")
) # includes **kwargs
nodes.append( Node(id="Captain_Marvel",
size=25,
shape="circularImage",
image="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_captainmarvel.png")
)
edges.append( Edge(source="Captain_Marvel",
label="friend_of",
target="Spiderman",
# **kwargs
)
)
config = Config(width=500,
height=500,
# **kwargs
)
return_value = agraph(nodes=nodes,
edges=edges,
config=config)
You may also want to use the TripleStore (untested & incomplete - yet):
# Currently not workin since update to agraph 2.0 - work in progress
from rdflib import Graph
from streamlit_agraph import TripleStore, agraph
graph = Graph()
graph.parse("http://www.w3.org/People/Berners-Lee/card")
store = TripleStore()
for subj, pred, obj in graph:
store.add_triple(subj, pred, obj, "")
agraph(list(store.getNodes()), list(store.getEdges()), config)
Also graph algos can dirctly supported via the networkx API (untested & incomplete - yet):
from streamlit_agraph import GraphAlgos
algos = GraphAlgos(store)
algos.shortest_path("Spiderman", "Captain_Marvel")
algos.density()
Formating the graph with hierachies is also possible, see examples/iris_decision_tree.py
:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for streamlit_agraph-0.0.42-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 009714619513f78f34671f353bcc74e2484a60d13553af104ed0eb45ad48bba7 |
|
MD5 | d7af5f8c73bfca562e900c0bf7a86183 |
|
BLAKE2b-256 | ef4b170044c15b7b16b8bfa590ad8226e097d2a27351bb81c4a67b5ee6edd66c |