Based on react-graph-vis
Install
pip install streamlit-agraph
Example App
Check out the example App!
Basic Usage
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=750,
height=950,
directed=True,
physics=True,
hierarchical=False,
# **kwargs
)
return_value = agraph(nodes=nodes,
edges=edges,
config=config)
Config Bilder
from streamlit_agraph.config import Config, ConfigBuilder
# 1. Build the config (with sidebar to play with options) .
config_builder = ConfigBuilder(nodes)
config = config_builder.build()
# 2. If your done, save the config to a file.
config.save("config.json")
# 3. Simple reload from json file (you can bump the builder at this point.)
config = Config(from_json="config.json")
Formating the graph with hierachies is also possible via Hierarchical Option (see config):
Group as you can see on the node colors too. Just pass the group attribute to the Node object.
TripleStore
You may also want to use the TripleStore (untested & incomplete - yet):
HINT: Make sure to add only unique nodes and edges.
# 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()
Metadata
Release files for streamlit-agraph 0.0.45
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| streamlit-agraph-0.0.45.tar.gz | 1.3 MB | Without provenance | Details for streamlit-agraph-0.0.45.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| streamlit_agraph-0.0.45-py3-none-any.whl | Python 3 | none | any | Details for streamlit_agraph-0.0.45-py3-none-any.whl |
Total release size: 2.6 MB
Release files / streamlit-agraph-0.0.45.tar.gz
| Download URL | streamlit-agraph-0.0.45.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2b7cf1ad0a40dc906de50792b27f2878b0e186603cb3bc958ed78ca7e469cdd
|
|
BLAKE2b-256 checksum How to use checksums |
e66300a16b1500cde32d43177bba1c16d12369ed7d1c8b45ab8162f6552d8519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.6.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|
Release files / streamlit_agraph-0.0.45-py3-none-any.whl
| Download URL | streamlit_agraph-0.0.45-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38e7271ffd76a6769968c2e9dfc16cbac7621d62be15af98b62598e1446bee2f
|
|
BLAKE2b-256 checksum How to use checksums |
b9808a666e700332a9fe19e458678c95fab4d78340251d2f12da7d2ad915458a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.6.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|
Security for streamlit-agraph 0.0.45
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.