File size: 1,513 Bytes
6207b87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import streamlit as st
from streamlit_agraph import agraph, Node, Edge, Config


c1, c2 = st.columns(2)


with c1:

    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)

with c2:
    # 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)