Skip to content

Commit

Permalink
Don’t fail on missing python-igraph unless we actually need it
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Jul 26, 2020
1 parent df110bb commit fd263bd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/macrogen/graph.py
Expand Up @@ -28,7 +28,6 @@
from .graphutils import simplify_timeline
from .fes import eades, FES_Baharev, V
from .graphutils import expand_edges, collapse_edges_by_source, add_iweight
from .igraph_wrapper import to_igraph, nx_edges
from .uris import Reference, Inscription, Witness, AmbiguousRef
from .splitgraph import references, SplitReference, Side

Expand Down Expand Up @@ -182,9 +181,14 @@ def feedback_arcs(self, graph: nx.MultiDiGraph, method=None, light_timeline: Opt
else:
if light_timeline:
logger.warning('Method %s does not support lightweight timeline', method)
igraph = to_igraph(graph)
iedges = igraph.es[igraph.feedback_arc_set(method=method, weights='weight')]
return list(nx_edges(iedges, keys=True, data=True))
try:
from .igraph_wrapper import to_igraph, nx_edges
igraph = to_igraph(graph)
iedges = igraph.es[igraph.feedback_arc_set(method=method, weights='weight')]
return list(nx_edges(iedges, keys=True, data=True))
except ImportError as e:
logger.critical('The method %s requires python-igraph, but it is not available: %s', method, e, exc_info=True)


def run_analysis(self):
"""
Expand Down

0 comments on commit fd263bd

Please sign in to comment.