diff --git a/arelight/backend/d3js/relations_graph_builder.py b/arelight/backend/d3js/relations_graph_builder.py index 47d87f9..3bc9a23 100644 --- a/arelight/backend/d3js/relations_graph_builder.py +++ b/arelight/backend/d3js/relations_graph_builder.py @@ -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} diff --git a/arelight/backend/d3js/relations_graph_operations.py b/arelight/backend/d3js/relations_graph_operations.py index a455779..88eacc1 100644 --- a/arelight/backend/d3js/relations_graph_operations.py +++ b/arelight/backend/d3js/relations_graph_operations.py @@ -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: