S2GraphBuilder

Warning

This module is under active development and may change significantly in future versions.

class s2.graph.S2GraphBuilder(graph=<s2.graph.graph.S2Graph object>, hopper=<s2.graph.hopper.MaxHopHopper object>, queue=deque([]), discovered_from=None, not_found=None, colliding_paperIds=None, log_every=10, save_path=None, **api_kwargs)

Builds an S2Graph object.

Parameters
  • graph (S2Graph) – The S2Graph object to build or continue buiding.

  • hopper (GraphHopper) – The GraphHopper object that defines the strategy for building the citation network subgraph.

  • queue (Deque) – A queue of papers that remain to be added. Everytime a paper is added, all its neighbours are added to the queue and the hopper will decide whether these papers should also be added.

  • discovered_from (Optional[Dict[PaperId, HopFrom]]) – A dictionary for reconstructing graph paths.

  • not_found (Optional[Set]) – A set of paper identifiers that were not found, to allow subsequent follow-up.

  • colliding_paperIds (Optional[Dict[PaperId, Set[PaperId]]]) – A dictionary of papers with inconsistent identifiers.

  • log_every (int) – Log updates every x paper added.

  • save_path (Union[Path, str, None]) – Where to save progress in event of interruption.

  • **api_kwargs – Additional kwargs for the ::`` module.

_add_to_queue(ref, source, edge_type)

Add ref to queue, record ref visit, and add edge from source to ref.

Return type

None

_get_gpath(paperId)

Get the path that was traversed to reach paperId in the S2Graph.

Return type

GraphPath

_get_paper(paperId)

Get an S2Paper via its paperId, checking local db first.

Return type

S2Paper

from_paper_id(paperId)

Construct S2Graph from PaperId based on GraphHopper strategy.

Parameters

paperId (str) – S2 paper identifier (see get_paper() for more info)