Exemplo n.º 1
0
    def connected_segments(self):

        from graph import connected_component_algorithm as cca
        res = cca.connected_components(graph=self.graph)
        atom_for = self.atom_for

        return [[atom_for[v] for v in comp] for comp in res]
Exemplo n.º 2
0
  def connected_segments(self):

    from graph import connected_component_algorithm as cca
    res = cca.connected_components( graph = self.graph )
    atom_for = self.atom_for

    return [ [ atom_for[ v ] for v in comp ] for comp in res ]
    def manipulation(self, g):

        vd1 = g.add_vertex()
        vd2 = g.add_vertex()
        vd3 = g.add_vertex()

        g.add_edge(vertex1=vd1, vertex2=vd2)
        components = cca.connected_components(graph=g)

        self.assertEqual(len(components), 2)
        self.assertEqual(set([frozenset(c) for c in components]), set([frozenset([vd1, vd2]), frozenset([vd3])]))
    def manipulation(self, g):

        vd1 = g.add_vertex()
        vd2 = g.add_vertex()
        vd3 = g.add_vertex()

        g.add_edge(vertex1=vd1, vertex2=vd2)
        components = cca.connected_components(graph=g)

        self.assertEqual(len(components), 2)
        self.assertEqual(
            set([frozenset(c) for c in components]),
            set([frozenset([vd1, vd2]),
                 frozenset([vd3])]),
        )