Skip to content
Snippets Groups Projects
Commit b9f33780 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Generalize input of `extract_component.py`

Generalize `extract_component.py` so it can also read a graph in
graph-tool or graphml format.
parent c2c14e48
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,20 @@
import graph_tool
import csv
from graph_tool import topology
import pathlib
import sys
input_suffix = pathlib.Path(sys.argv[1]).suffix
if input_suffix == ".csv":
g = graph_tool.load_graph_from_csv(sys.argv[1], directed = True,
csv_options = {'delimiter': ' ',
'skipinitialspace': True})
elif input_suffix in {".gt", ".graphml"}:
g = graph_tool.load_graph(sys.argv[1])
else:
sys.exit('Bad input file suffix.')
g = graph_tool.load_graph_from_csv("edgelist.csv", directed = True,
csv_options = {'delimiter': ' ',
'skipinitialspace': True})
g.set_directed(False)
for v in g.vertices():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment