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
S2Graphobject.- Parameters
graph (
S2Graph) – TheS2Graphobject to build or continue buiding.hopper (
GraphHopper) – TheGraphHopperobject 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 thehopperwill 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
-
_get_gpath(paperId)¶ Get the path that was traversed to reach
paperIdin theS2Graph.- Return type
GraphPath
-
from_paper_id(paperId)¶ Construct
S2GraphfromPaperIdbased onGraphHopperstrategy.- Parameters
paperId (
str) – S2 paper identifier (seeget_paper()for more info)