MCPcopy
hub / github.com/jwngr/sdow / compute_shortest_paths

Method compute_shortest_paths

sdow/database.py:112–132  ·  view source on GitHub ↗

Returns a list of page IDs indicating the shortest path between the source and target pages. Note: the provided page IDs must correspond to non-redirect pages, but that check is not made for performance reasons. Args: source_page_id: The ID corresponding to the page at which to s

(self, source_page_id, target_page_id)

Source from the content-addressed store, hash-verified

110 return page_title[0].replace('_', ' ')
111
112 def compute_shortest_paths(self, source_page_id, target_page_id):
113 """Returns a list of page IDs indicating the shortest path between the source and target pages.
114
115 Note: the provided page IDs must correspond to non-redirect pages, but that check is not made
116 for performance reasons.
117
118 Args:
119 source_page_id: The ID corresponding to the page at which to start the search.
120 target_page_id: The ID corresponding to the page at which to end the search.
121
122 Returns:
123 list(list(int)): A list of integer lists corresponding to the page IDs indicating the shortest path
124 between the source and target page IDs.
125
126 Raises:
127 ValueError: If either of the provided page IDs are invalid.
128 """
129 helpers.validate_page_id(source_page_id)
130 helpers.validate_page_id(target_page_id)
131
132 return breadth_first_search(source_page_id, target_page_id, self)
133
134 def fetch_outgoing_links_count(self, page_ids):
135 """Returns the sum of outgoing links of the provided page IDs.

Callers 1

shortest_paths_routeFunction · 0.80

Calls 1

breadth_first_searchFunction · 0.90

Tested by

no test coverage detected