summarization.commons
– Common graph functions¶This module provides functions of creating graph from sequence of values and removing of unreachable nodes.
Examples
Create simple graph and add edges. Let’s take a look at nodes.
>>> gg = build_graph(['Felidae', 'Lion', 'Tiger', 'Wolf'])
>>> gg.add_edge(("Felidae", "Lion"))
>>> gg.add_edge(("Felidae", "Tiger"))
>>> sorted(gg.nodes())
['Felidae', 'Lion', 'Tiger', 'Wolf']
Remove nodes with no edges.
>>> remove_unreachable_nodes(gg)
>>> sorted(gg.nodes())
['Felidae', 'Lion', 'Tiger']
gensim.summarization.commons.
build_graph
(sequence)¶Creates and returns undirected graph with given sequence of values.
sequence (list of hashable) – Sequence of values.
Created graph.