def add_overlay( self, name, nodes=None, graph=None, directed=False, multi_edge=False, retain=None, ): """Adds overlay graph of name name""" if graph: if not directed and graph.is_directed(): log.info('Converting graph %s to undirected' % name) graph = nx.Graph(graph) elif directed: if multi_edge: graph = nx.MultiDiGraph() else: graph = nx.DiGraph() else: if multi_edge: graph = nx.MultiGraph() else: graph = nx.Graph() self._overlays[name] = graph overlay = NmGraph(self, name) overlay.allocate_interfaces() if nodes: retain = retain or [] # default is an empty list overlay.add_nodes_from(nodes, retain) return overlay
def overlay(self, key): """Get to other overlay graphs in functions""" # TODO: refactor: shouldn't be returning concrete instantiation from abstract parent! from autonetkit.anm.graph import NmGraph return NmGraph(self._anm, key)
def add_overlay(self, name, nodes=None, graph=None, directed=False, multi_edge=False, retain=None): """Adds overlay graph of name name""" # TODO: refactor this logic log.debug("Adding overlay %s" % name) multi_edge = multi_edge or self.all_multigraph if graph: if not directed and graph.is_directed(): if multi_edge or graph.is_multigraph(): new_graph = nx.MultiGraph(graph) else: # TODO: put into dev log log.debug('Converting graph %s to undirected' % name) new_graph = nx.Graph(graph) else: if multi_edge or graph.is_multigraph(): new_graph = nx.MultiGraph(graph) else: new_graph = nx.Graph(graph) elif directed: if multi_edge: new_graph = nx.MultiDiGraph() else: new_graph = nx.DiGraph() else: if multi_edge: new_graph = nx.MultiGraph() else: new_graph = nx.Graph() self._overlays[name] = new_graph overlay = NmGraph(self, name) if nodes: retain = retain or [] # default is an empty list overlay.add_nodes_from(nodes, retain) return overlay
def add_overlay( self, name, nodes=None, graph=None, directed=False, multi_edge=False, retain=None, ): """Adds overlay graph of name name""" # TODO: refactor this logic log.debug("Adding overlay %s" % name) multi_edge = multi_edge or self.all_multigraph if graph: if not directed and graph.is_directed(): if multi_edge: new_graph = nx.MultiGraph(graph) else: log.info('Converting graph %s to undirected' % name) new_graph = nx.Graph(graph) else: new_graph = nx.Graph(graph) elif directed: if multi_edge: new_graph = nx.MultiDiGraph() else: new_graph = nx.DiGraph() else: if multi_edge: new_graph = nx.MultiGraph() else: new_graph = nx.Graph() self._overlays[name] = new_graph overlay = NmGraph(self, name) if nodes: retain = retain or [] # default is an empty list overlay.add_nodes_from(nodes, retain) return overlay
def _overlay(self): """Access overlay graph for this node""" from autonetkit.anm.graph import NmGraph return NmGraph(self.anm, self.overlay_id)
def __getitem__(self, key): """""" from autonetkit.anm.graph import NmGraph overlay = NmGraph(self.anm, key) return overlay.edge(self)
def _overlay(self): return NmGraph(self.anm, self.overlay_id)
def overlay(self, key): """""" return NmGraph(self, key)
def __getitem__(self, key): """""" return NmGraph(self, key)
def __iter__(self): return iter(NmGraph(self, name) for name in self.overlays())
def _phy(self): """""" return NmGraph(self, 'phy')
def _overlay(self): from autonetkit.anm import NmGraph return NmGraph(self.anm, self.overlay_id)