-
Notifications
You must be signed in to change notification settings - Fork 1
/
agraph.py
30 lines (26 loc) · 921 Bytes
/
agraph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import streamlit
from streamlit_agraph import agraph, Node, Edge, Config
import pandas as pd
import numpy as np
def get_graph(file):
nodes = []
edges = []
df = pd.read_csv(file)
for x in np.unique(df[["Source", "Target"]].values):
nodes.append(Node(id=x))
for index, row in df.iterrows():
edges.append(Edge(source=row["Source"], target=row["Target"], type="CURVE_SMOOTH"))
config = Config(width=600,
height=600,
directed=False,
nodeHighlightBehavior=True,
highlightColor="#F7A7A6", # or "blue"
collapsible=True,
# coming soon (set for all): node_size=1000, node_color="blue"
)
return_value = agraph(nodes=nodes,
edges=edges,
config=config)
return return_value
def app():
get_graph("BERT_edge_list2.csv")