Skip to content

Commit

Permalink
#150 related update
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Jul 15, 2024
1 parent 59bc6cf commit a5eb480
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arelight/backend/d3js/relations_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ def __get_type(v):
node_max = max(used_nodes.values()) if used_nodes else 0
nodes = [{"id": id, "c": used_nodes[id]/node_max if weights else 1} for id in used_nodes]

return {"basis": graph_name, "nodes": nodes, "links": links}
return {"basis": [graph_name], "equation": "["+graph_name+"]", "nodes": nodes, "links": links}
8 changes: 6 additions & 2 deletions arelight/backend/d3js/relations_graph_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ def link_key(link):
used_nodes[t] = used_nodes.get(t, 0) + c

nodes = [{"id": id, "c": c} for id, c in used_nodes.items()]
basis = "(" + graph_A["basis"] + ")" + OPERATION_MAP[operation] + "(" + graph_B["basis"] + ")"
result_graph = {"basis": basis, "nodes": nodes, "links": links}
if operation == OP_DIFFERENCE:
basis = list(set(graph_A["basis"])-set(graph_B["basis"]))
else:
basis = list(set(graph_A["basis"])+set(graph_B["basis"]))
equation = "(" + graph_A["equation"] + ")" + OPERATION_MAP[operation] + "(" + graph_B["equation"] + ")"
result_graph = {"basis": basis, "equation": equation, "nodes": nodes, "links": links}

# Assign weights if not used.
if not weights:
Expand Down

0 comments on commit a5eb480

Please sign in to comment.