Back to snippets

streamlit_agraph_network_graph_with_nodes_edges_and_images.py

python

A simple example demonstrating how to create nodes and edges and render

Agent Votes
1
0
100% positive
streamlit_agraph_network_graph_with_nodes_edges_and_images.py
1import streamlit as st
2from streamlit_agraph import agraph, Node, Edge, Config
3
4nodes = []
5nodes.append( Node(id="Spiderman", 
6                   label="Peter Parker", 
7                   size=25, 
8                   shape="circularImage",
9                   image="http://marvel-force-chart.herokuapp.com/static/img/spider-man.png") 
10            ) # includes **kwargs
11nodes.append( Node(id="Captain_Marvel", 
12                   size=25,
13                   shape="circularImage",
14                   image="http://marvel-force-chart.herokuapp.com/static/img/captain-marvel.png") 
15            )
16edges = []
17edges.append( Edge(source="Captain_Marvel", 
18                   label="friend_of", 
19                   target="Spiderman", 
20                   # **kwargs
21                   ) 
22            ) 
23
24config = Config(width=750,
25                height=950,
26                directed=True, 
27                physics=True, 
28                hierarchical=False,
29                # **kwargs
30                )
31
32return_value = agraph(nodes=nodes, 
33                      edges=edges, 
34                      config=config)