src/pybel/io/triples/api.py
def to_triples(graph: BELGraph, use_tqdm: bool = False, raise_on_none: bool = False) -> List[Tuple[str, str, str]]:
    """Get a non-redundant list of triples representing the graph.

    :param graph: A BEL graph
    :param use_tqdm: Should a progress bar be shown?
    :param raise_on_none: Should an exception be raised if no triples are returned?
    :raises: NoTriplesValueError
    """
    it = graph.edges(keys=True)

    if use_tqdm:
        it = tqdm(
            it,
            total=graph.number_of_edges(),
            desc='Preparing TSV for {}'.format(graph),
            unit_scale=True,
            unit='edge',
        )

    triples = (
        to_triple(graph, u, v, key)
        for u, v, key in it
    )

    # clean duplicates and Nones
    rv = list(
        sorted({
            triple
            for triple in triples
            if triple is not None
        }),
    )
    if raise_on_none and not rv:
        raise NoTriplesValueError('Could not convert any triples')
    return rv
Get a non-redundant list of triples representing the graph.

    :param graph: A BEL graph
    :param use_tqdm: Should a progress bar be shown?
    :param raise_on_none: Should an exception be raised if no triples are returned?
    :raises: NoTriplesValueError
    
Get a non-redundant list of triples representing the graph.
Get a non - redundant list of triples representing the graph .
def to_triples(graph: BELGraph, use_tqdm: bool = False, raise_on_none: bool = False) -> List[Tuple[str, str, str]]:
    it = graph.edges(keys=True)
    if use_tqdm:
        it = tqdm(
            it,
            total=graph.number_of_edges(),
            desc='Preparing TSV for {}'.format(graph),
            unit_scale=True,
            unit='edge',
        )
    triples = (
        to_triple(graph, u, v, key)
        for u, v, key in it
    )
    rv = list(
        sorted({
            triple
            for triple in triples
            if triple is not None
        }),
    )
    if raise_on_none and not rv:
        raise NoTriplesValueError('Could not convert any triples')
    return rv
def to_triples ( graph : BELGraph , use_tqdm : bool = False , raise_on_none : bool = False ) -> List [ Tuple [ str , str , str ] ] : it = graph . edges ( keys = True ) if use_tqdm : it = tqdm ( it , total = graph . number_of_edges ( ) , desc = 'Preparing TSV for {}' . format ( graph ) , unit_scale = True , unit = 'edge' , ) triples = ( to_triple ( graph , u , v , key ) for u , v , key in it ) rv = list ( sorted ( { triple for triple in triples if triple is not None } ) , ) if raise_on_none and not rv : raise NoTriplesValueError ( 'Could not convert any triples' ) return rv
Get a non-redundant list of triples representing the graph.
Get a non - redundant list of triples representing the graph .
"""Get a non-redundant list of triples representing the graph.

    :param graph: A BEL graph
    :param use_tqdm: Should a progress bar be shown?
    :param raise_on_none: Should an exception be raised if no triples are returned?
    :raises: NoTriplesValueError
    """ # clean duplicates and Nones
None
graph
BELGraph
A BEL graph
A BEL graph
use_tqdm
bool
None
raise_on_none
bool
None