示例#1
0
文件: stat.py 项目: imane-aanna/mtg-1
def extract_extremities(g, scale=0, **kwds):
    if scale <= 0:
        vid = first_component_root(g,g.root)
        scale = g.scale(vid)

    vids = g.component_roots_at_scale_iter(g.root, scale=scale)
    leaves = chain.from_iterable(algo.extremities(g,vid) for vid in vids)

    seqs = [list(reversed([vid for vid in algo.ancestors(g,lid)])) for lid in leaves]
    return seqs
示例#2
0
def extract_extremities(g, scale=0, **kwds):
    if scale <= 0:
        vid = first_component_root(g,g.root)
        scale = g.scale(vid)

    vids = g.component_roots_at_scale_iter(g.root, scale=scale)
    leaves = chain.from_iterable(algo.extremities(g,vid) for vid in vids)

    seqs = [list(reversed([vid for vid in algo.ancestors(g,lid)])) for lid in leaves]
    return seqs
示例#3
0
    def test_mtg_sequences(self):
        g = self.g
        topdia = g.property('TopDia')
        nfe = g.property('NFe')

        vid = g.component_roots_at_scale_iter(g.root, g.max_scale()).next()
        leaves = algo.extremities(g,vid)
        seqs = [list(reversed([vid for vid in algo.ancestors(g, lid) if vid in topdia and vid in nfe])) for lid in leaves]

        sequences = build_sequences(g,seqs,['TopDia', 'NFe'])
        return sequences
示例#4
0
文件: aml.py 项目: BeGIMATH/mtg
def Extremities(v, RestrictedTo='NoRestriction', ContainedIn=None):
    """
    Set of vertices that are the extremities of the branching system
    born by a given vertex.

    This function returns the extremities of the branching system defined by the argument
    as a list of vertices. These vertices have the same scale as `v` and their order in
    the list is not signifiant. The result is always a non empty array.

    :Usage:

    .. code-block:: python

        Extremities(v)

    :Properties:

        -  v (int) : vertex of the active MTG

    :Optional Parameters:

        - RestrictedTo (str): cf. :func:`Father`
        - ContainedIn (int): cf. :func:`Father`

    :Returns:

        list of vertices's id (int)


    :Examples:

    .. code-block:: python

        >>> Descendants(v)
        [3, 45, 47, 78, 102]
        >>> Extremities(v)
        [47, 102]

    .. seealso:: :func:`MTG`, :func:`Descendants`, :func:`Root`, :func:`MTGRoot`.
    """
    global _g
    return list(
        algo.extremities(_g,
                         v,
                         RestrictedTo=RestrictedTo,
                         ContainedIn=ContainedIn))
示例#5
0
文件: aml.py 项目: imane-aanna/mtg-1
def Extremities(v, RestrictedTo='NoRestriction', ContainedIn=None):
    """
    Set of vertices that are the extremities of the branching system
    born by a given vertex.

    This function returns the extremities of the branching system defined by the argument
    as a list of vertices. These vertices have the same scale as `v` and their order in
    the list is not signifiant. The result is always a non empty array.

    :Usage:

    .. code-block:: python

        Extremities(v)

    :Properties:

        -  v (int) : vertex of the active MTG

    :Optional Parameters:

        - RestrictedTo (str): cf. :func:`Father`
        - ContainedIn (int): cf. :func:`Father`

    :Returns:

        list of vertices's id (int)


    :Examples:

    .. code-block:: python

        >>> Descendants(v)
        [3, 45, 47, 78, 102]
        >>> Extremities(v)
        [47, 102]

    .. seealso:: :func:`MTG`, :func:`Descendants`, :func:`Root`, :func:`MTGRoot`.
    """
    global _g
    return list(algo.extremities(_g, v, RestrictedTo=RestrictedTo, ContainedIn=ContainedIn))