swh.graph.naive_client module

swh.graph.naive_client.check_arguments(f: swh.graph.naive_client.T) swh.graph.naive_client.T[source]

Decorator for generic argument checking for methods of NaiveClient. Checks src is a valid and known SWHID, and edges has the right format.

swh.graph.naive_client.filter_node_types(node_types: str, nodes: Iterable[str]) Iterator[str][source]
class swh.graph.naive_client.NaiveClient(*, nodes: List[str], edges: List[Tuple[str, str]])[source]

Bases: object

An alternative implementation of swh.graph.backend.Backend, written in pure-python and meant for simulating it in other components’ test cases.

It is NOT meant to be efficient in any way; only to be a very simple implementation that provides the same behavior.

stats() Dict[source]
leaves(src: str, edges: str = '*', direction: str = 'forward', max_edges: int = 0, return_types: str = '*') Iterator[str][source]
neighbors(src: str, edges: str = '*', direction: str = 'forward', max_edges: int = 0, return_types: str = '*') Iterator[str][source]
visit_nodes(src: str, edges: str = '*', direction: str = 'forward', max_edges: int = 0, return_types: str = '*') Iterator[str][source]
visit_edges(src: str, edges: str = '*', direction: str = 'forward', max_edges: int = 0) Iterator[Tuple[str, str]][source]
visit_paths(src: str, edges: str = '*', direction: str = 'forward', max_edges: int = 0) Iterator[List[str]][source]
walk(src: str, dst: str, edges: str = '*', traversal: str = 'dfs', direction: str = 'forward', limit: Optional[int] = None) Iterator[str][source]
random_walk(src: str, dst: str, edges: str = '*', direction: str = 'forward', limit: Optional[int] = None)[source]
count_leaves(src: str, edges: str = '*', direction: str = 'forward') int[source]
count_neighbors(src: str, edges: str = '*', direction: str = 'forward') int[source]
count_visit_nodes(src: str, edges: str = '*', direction: str = 'forward') int[source]
class swh.graph.naive_client.Graph(nodes: List[str], edges: List[Tuple[str, str]])[source]

Bases: object

get_filtered_neighbors(src: str, edges_fmt: str, direction: str) Set[str][source]
get_subgraph(src: str, edges_fmt: str, direction: str) Set[str][source]
iter_paths_dfs(direction: str, edges_fmt: str, src: str) Iterator[Tuple[str, ...]][source]
iter_edges_dfs(direction: str, edges_fmt: str, src: str) Iterator[Tuple[str, str]][source]
class swh.graph.naive_client.SubgraphIterator(graph: swh.graph.naive_client.Graph, direction: str, edges_fmt: str, src: str)[source]

Bases: Iterator[Tuple[Tuple[str, …], str]]

more_work() bool[source]
pop() Tuple[Tuple[str, ...], str][source]
push(new_path: Tuple[str, ...], neighbor: str) None[source]
class swh.graph.naive_client.DfsSubgraphIterator(*args, **kwargs)[source]

Bases: Iterator[Tuple[Tuple[str, …], str]]

more_work() bool[source]
pop() Tuple[Tuple[str, ...], str][source]
push(new_path: Tuple[str, ...], neighbor: str) None[source]