Commit ddfbe4f6 authored by Administrator's avatar Administrator

[FEATURE] Graph: adding group for colors.

parent c00ea6ed
...@@ -511,7 +511,6 @@ def node_link(request, corpus_id): ...@@ -511,7 +511,6 @@ def node_link(request, corpus_id):
weight[cooccurrence.ngramx.terms] = weight.get(cooccurrence.ngramx.terms, 0) + cooccurrence.score weight[cooccurrence.ngramx.terms] = weight.get(cooccurrence.ngramx.terms, 0) + cooccurrence.score
df = pd.DataFrame(matrix).T.fillna(0) df = pd.DataFrame(matrix).T.fillna(0)
x = copy(df.values) x = copy(df.values)
x = x / x.sum(axis=1) x = x / x.sum(axis=1)
...@@ -531,25 +530,18 @@ def node_link(request, corpus_id): ...@@ -531,25 +530,18 @@ def node_link(request, corpus_id):
# G.remove_nodes_from(to_remove) # G.remove_nodes_from(to_remove)
partition = best_partition(G) partition = best_partition(G)
#print(partition.items())
for node in G.nodes(): for node in G.nodes():
try: try:
#node,type(labels[node]) #node,type(labels[node])
G.node[node]['label'] = node G.node[node]['label'] = node
G.node[node]['size'] = weight[node] G.node[node]['size'] = weight[node]
# G.node[node]['color'] = '19,180,300' G.node[node]['group'] = partition[node]
G.add_edge(node, partition[node], weight=2)
except Exception as error: except Exception as error:
print(error) print(error)
data = json_graph.node_link_data(G) data = json_graph.node_link_data(G)
# data = json_graph.node_link_data(G, attrs={\
# 'source':'source',\
# 'target':'target',\
# 'weight':'weight',\
# #'label':'label',\
# #'color':'color',\
# 'id':'id',})
#print(data)
return JsonHttpResponse(data) return JsonHttpResponse(data)
def graph_it(request): def graph_it(request):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment