예제 #1
0
    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
예제 #2
0
    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)
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    def _overlay(self):
        """Access overlay graph for this node"""

        from autonetkit.anm.graph import NmGraph
        return NmGraph(self.anm, self.overlay_id)
예제 #6
0
파일: edge.py 프로젝트: byouloh/autonetkit
    def __getitem__(self, key):
        """"""

        from autonetkit.anm.graph import NmGraph
        overlay = NmGraph(self.anm, key)
        return overlay.edge(self)
예제 #7
0
 def _overlay(self):
     return NmGraph(self.anm, self.overlay_id)
예제 #8
0
    def __getitem__(self, key):
        """"""

        from autonetkit.anm.graph import NmGraph
        overlay = NmGraph(self.anm, key)
        return overlay.edge(self)
예제 #9
0
    def overlay(self, key):
        """"""

        return NmGraph(self, key)
예제 #10
0
    def __getitem__(self, key):
        """"""

        return NmGraph(self, key)
예제 #11
0
 def __iter__(self):
     return iter(NmGraph(self, name) for name in self.overlays())
예제 #12
0
    def _phy(self):
        """"""

        return NmGraph(self, 'phy')
예제 #13
0
파일: edge.py 프로젝트: yijxiang/autonetkit
 def _overlay(self):
     from autonetkit.anm import NmGraph
     return NmGraph(self.anm, self.overlay_id)