예제 #1
0
파일: topology.py 프로젝트: pradal/groalea
def spanning_mtg(graph):
    """ Extract an MTG from the GroIMP graph.

    Parameters
    ----------
        - graph is a RootedGraph created from the GroIMP Graph

    TODO:
        - compress vertices to only usefull vertices (geometry)
        - compress edges to spanning mtg
    """
    # Manage a mapping between the graph and the mtg
    graph2mtg = {}
    g = graph
    edge_type = g.edge_property('edge_type')

    mtg = MTG()

    mtg.root = graph.root

    # Check if the graph contains decomposition (/) edges
    if not is_multiscale(graph):
        pass

    # Compute the scale from each vertex.
    # Select one decomposition path if there are several in the GroIMP graph
    _scales = scales(g)

    # Set the internal scale information to the MTG
    mtg._scale = _scales

    # Set the edge_type for each vertex (<, +)
    _edge_type = _build_edge_type(g, mtg)

    # Compute the tree information at all scales
    _children_and_parent(g, mtg)

    # Compute the complex (upscale) and components (downscale) for each vertex
    _complex_and_components(g, mtg)

    print "scales :", mtg._scale
    # Extract all the vertex properties.
    _vertex_properties(g, mtg)

    # Compute missing links to have constant time access (O(1)) to neighbourhood
    fat_mtg(mtg)
    print "scales :", mtg._scale

    return mtg
예제 #2
0
def spanning_mtg(graph):
    """ Extract an MTG from the GroIMP graph.

    Parameters
    ----------
        - graph is a RootedGraph created from the GroIMP Graph

    TODO:
        - compress vertices to only usefull vertices (geometry)
        - compress edges to spanning mtg
    """
    # Manage a mapping between the graph and the mtg
    graph2mtg = {}
    g = graph
    edge_type = g.edge_property('edge_type')

    mtg = MTG()

    mtg.root = graph.root

    # Check if the graph contains decomposition (/) edges
    if not is_multiscale(graph):
        pass

    # Compute the scale from each vertex.
    # Select one decomposition path if there are several in the GroIMP graph
    _scales = scales(g)

    # Set the internal scale information to the MTG
    mtg._scale = _scales

    # Set the edge_type for each vertex (<, +)
    _edge_type = _build_edge_type(g, mtg)

    # Compute the tree information at all scales
    _children_and_parent(g, mtg)

    # Compute the complex (upscale) and components (downscale) for each vertex
    _complex_and_components(g, mtg)

    print "scales :", mtg._scale
    # Extract all the vertex properties.
    _vertex_properties(g, mtg)

    # Compute missing links to have constant time access (O(1)) to neighbourhood
    fat_mtg(mtg)
    print "scales :", mtg._scale

    return mtg