def get_fbvs(self, graph: Graph): if is_acyclic(graph): return set() # remove all nodes of degree 0 or 1 as they can't be part of any cycles remove_node_deg_01(graph) # reset the cache dict self.cacheDict = {} return self._get_fbvs(graph)
def get_fbvs(self, graph: Graph): if is_acyclic(graph): return set() # remove all nodes of degree 0 or 1 as they can't be part of any cycles remove_node_deg_01(graph) nodes = graph.nodes() for L in range(0, len(nodes) + 1): for subset in itertools.combinations(nodes, L): # make an induced subgraph with the current node subset removed new_graph = graph_minus(graph, subset) if is_acyclic(new_graph): return subset return set()
def get_fbvs(self, graph: Graph): if is_acyclic(graph): return set() # remove all nodes of degree 0 or 1 as they can't be part of any cycles remove_node_deg_01(graph) # get the set of nodes that is in at least one cycle cycles = cycle_basis(graph) nodes_in_cycles = set([item for sublist in cycles for item in sublist]) for L in range(0, len(nodes_in_cycles) + 1): for subset in itertools.combinations(nodes_in_cycles, L): # make an induced subgraph with the current node subset removed new_graph = graph_minus(graph, subset) if is_acyclic(new_graph): return subset return set()