Commit 0f0814d4 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

simplification with multiple components

parent 448f02f1
......@@ -13,6 +13,7 @@ def parse_arguments():
parser.add_argument('barcode_graph', help='The barcode graph file. Must be a gefx formated file.')
parser.add_argument('d2_graph', help='d2 graph to reduce. Must be a gefx formated file.')
parser.add_argument('--output_d2_name', '-o', default="transitively_reduced_d2.gexf", help="Output file prefix.")
parser.add_argument('--component_min_size', '-c', type=int, default=10, help="Minimum size of a component to keep it in the d2-graph, after the edge simplifications.")
args = parser.parse_args()
return args
......@@ -37,11 +38,14 @@ def main():
# Take the principal component
largest_component_nodes = max(nx.connected_components(d2g), key=len)
largest_component = d2g.subgraph(largest_component_nodes)
# Write the simplificated graph
nx.write_gexf(largest_component, args.output_d2_name)
components = [c for c in nx.connected_components(d2g) if len(c) > args.component_min_size]
nodes = set()
for comp in components:
subgraph = d2g.subgraph(nodes)
# Write the simplified graph
nx.write_gexf(subgraph, args.output_d2_name)
if __name__ == "__main__":
Supports Markdown
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