Spaces:
Running
Running
Display the real graph.
Browse files- server/basic_ops.py +7 -19
- web/src/LynxKiteFlow.svelte +0 -1
server/basic_ops.py
CHANGED
@@ -19,26 +19,14 @@ def compute_pagerank(graph: nx.Graph, *, damping: 0.85, iterations: 3):
|
|
19 |
|
20 |
@ops.op("Visualize graph")
|
21 |
def visualize_graph(graph: ops.Bundle) -> 'graph_view':
|
|
|
|
|
|
|
22 |
return {
|
23 |
-
'attributes': {
|
24 |
-
|
25 |
-
},
|
26 |
-
'
|
27 |
-
'allowSelfLoops': True,
|
28 |
-
'multi': False,
|
29 |
-
'type': 'mixed'
|
30 |
-
},
|
31 |
-
'nodes': [
|
32 |
-
{'key': 'Thomas'},
|
33 |
-
{'key': 'Eric'}
|
34 |
-
],
|
35 |
-
'edges': [
|
36 |
-
{
|
37 |
-
'key': 'T->E',
|
38 |
-
'source': 'Thomas',
|
39 |
-
'target': 'Eric',
|
40 |
-
}
|
41 |
-
]
|
42 |
}
|
43 |
|
44 |
@ops.op("View table")
|
|
|
19 |
|
20 |
@ops.op("Visualize graph")
|
21 |
def visualize_graph(graph: ops.Bundle) -> 'graph_view':
|
22 |
+
nodes = graph.dfs['nodes']['id'].tolist()
|
23 |
+
edges = graph.dfs['edges'].drop_duplicates(['source', 'target'])
|
24 |
+
edges = edges.to_dict(orient='records')
|
25 |
return {
|
26 |
+
'attributes': {},
|
27 |
+
'options': {},
|
28 |
+
'nodes': [{'key': id} for id in nodes],
|
29 |
+
'edges': [{'key': str(r['source']) + ' -> ' + str(r['target']), **r} for r in edges],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
@ops.op("View table")
|
web/src/LynxKiteFlow.svelte
CHANGED
@@ -107,7 +107,6 @@
|
|
107 |
}
|
108 |
const ws = orderedJSON(g);
|
109 |
if (ws === backendWorkspace) return;
|
110 |
-
console.log('current vs backend', '\n' + ws, '\n' + backendWorkspace);
|
111 |
backendWorkspace = ws;
|
112 |
const res = await fetch('/api/save', {
|
113 |
method: 'POST',
|
|
|
107 |
}
|
108 |
const ws = orderedJSON(g);
|
109 |
if (ws === backendWorkspace) return;
|
|
|
110 |
backendWorkspace = ws;
|
111 |
const res = await fetch('/api/save', {
|
112 |
method: 'POST',
|