Exemple #1
0
 def __init__(self, attrs=None, mutable=True, *args, **kwargs):
     SimpleEdge.__init__(self, *args, **kwargs)
     if attrs == None:
         self.__attrs = dict()
     else:
         self.__attrs = dict(attrs)
     self.__mutable = mutable
Exemple #2
0
 def __create_edge(self, edges, from_file, to_file):
     # TODO strip external absolute base dirs and replace by <name of external module>
     from_file_stripped = self.__include_path_mapper.map_dir_to_external_module(
         from_file)
     to_file_stripped = self.__include_path_mapper.map_dir_to_external_module(
         to_file)
     edges.append(SimpleEdge(from_file_stripped, to_file_stripped))
Exemple #3
0
 def lookup_edge(self, source, target):
     # TODO das ist unnötig ineffizient (O(n)), vielleicht doch besser ein dict für die Kanten benutzen?
     for edge in self.__edges:
         if edge == SimpleEdge(source, target):
             return edge
     return None
Exemple #4
0
 def has_edge(self, source, target):
     return SimpleEdge(source, target) in self.__edges
Exemple #5
0
 def _remove_edge(self, source=None, target=None, edge=None):
     if not isinstance(edge, NoneType):
         self.__edges.remove(edge)
     else:
         self.__edges.remove(SimpleEdge(source, target))
Exemple #6
0
 def _add_edge(self, source, target):
     if SimpleEdge(source, target) not in self.__edges:
         self.__edges.add(AttributedEdge(attrs=dict(self.__default_edge_attrs),
                                         from_node=source,
                                         to_node=target))
Exemple #7
0
 def test_basic(self):
     graph = AttributeGraph(
         edges=(SimpleEdge(from_node="a", to_node="b"), ))
     self._run_with_graph(graph)