Commit d5486b14 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

prepare d2 graph to realoding by moving construction steps to annexe functions

parent 36834b36
......@@ -7,10 +7,12 @@ from d_graph import compute_all_max_d_graphs, filter_dominated, list_domination_
class D2Graph(object):
"""D2Graph (read it (d-graph)²)"""
def __init__(self, graph, index_size=3, verbose=True, debug=False):
def __init__(self, graph):
super(D2Graph, self).__init__()
self.graph = graph
def construct_from_barcodes(self, index_size=3, verbose=True, debug=False):
# Compute all the d-graphs
if verbose:
print("Compute the unit d-graphs")
......@@ -67,6 +69,10 @@ class D2Graph(object):
fp.write(f"{d_graph.idx} {neighbor_idx} {dist}\n")
def load_from_gexf(self, filename):
pass
def create_index_from_tuples(self, tuple_size=3):
index = {}
......
......@@ -26,7 +26,8 @@ def main():
G = nx.read_gexf(filename)
# Index size must be changed for general purpose. 8 is good for d=5
d2g = d2.D2Graph(G, index_size=8)
d2g = d2.D2Graph(G)
d2g.construct_from_barcodes(index_size=8)
d2g.save(f"{args.output_prefix}.tsv")
G, names = d2g.to_nx_graph()
......
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