Skip to main content

Interactive Graph Vis for Streamlit.

Project description

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.

marvel.png

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()

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

streamlit-agraph-0.0.45.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_agraph-0.0.45-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file streamlit-agraph-0.0.45.tar.gz.

File metadata

  • Download URL: streamlit-agraph-0.0.45.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for streamlit-agraph-0.0.45.tar.gz
Algorithm Hash digest
SHA256 b2b7cf1ad0a40dc906de50792b27f2878b0e186603cb3bc958ed78ca7e469cdd
MD5 c86f3540ea1b05083710c0f5f3e880c8
BLAKE2b-256 e66300a16b1500cde32d43177bba1c16d12369ed7d1c8b45ab8162f6552d8519

See more details on using hashes here.

File details

Details for the file streamlit_agraph-0.0.45-py3-none-any.whl.

File metadata

  • Download URL: streamlit_agraph-0.0.45-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for streamlit_agraph-0.0.45-py3-none-any.whl
Algorithm Hash digest
SHA256 38e7271ffd76a6769968c2e9dfc16cbac7621d62be15af98b62598e1446bee2f
MD5 85a2148bb111a039b6c749eb156ff871
BLAKE2b-256 b9808a666e700332a9fe19e458678c95fab4d78340251d2f12da7d2ad915458a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page