From 10653859f4a0d0dd3d8178db4f83e4919e75ebcc Mon Sep 17 00:00:00 2001 From: miratepuffin Date: Wed, 21 Aug 2024 15:21:02 +0100 Subject: [PATCH] update stubs + black --- python/python/raphtory/__init__.pyi | 1366 ++++++----------- .../python/raphtory/algorithms/__init__.pyi | 1 + python/python/raphtory/graphql/__init__.pyi | 23 +- python/tests/test_algorithms.py | 18 +- python/tests/test_graphql.py | 2 +- 5 files changed, 519 insertions(+), 891 deletions(-) diff --git a/python/python/raphtory/__init__.pyi b/python/python/raphtory/__init__.pyi index 2bc0a333f..0fce22b98 100644 --- a/python/python/raphtory/__init__.pyi +++ b/python/python/raphtory/__init__.pyi @@ -8,10 +8,8 @@ ############################################################################### class AlgorithmResult: - def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def get(self, key): """ Returns the value corresponding to the provided key @@ -19,7 +17,6 @@ class AlgorithmResult: Arguments: key: The key of type `H` for which the value is to be retrieved. """ - def get_all(self): """ Returns a Dict containing all the nodes (as keys) and their corresponding values (values) or none. @@ -27,10 +24,8 @@ class AlgorithmResult: Returns: A dict of nodes and their values """ - def get_all_values(self): """Returns a a list of all values""" - def get_all_with_names(self): """ Returns a dict with node names and values @@ -38,7 +33,6 @@ class AlgorithmResult: Returns: a dict with node names and values """ - def group_by(self): """ Groups the `AlgorithmResult` by its values. @@ -47,16 +41,12 @@ class AlgorithmResult: A `HashMap` where keys are unique values from the `AlgorithmResult` and values are vectors containing keys of type `H` that share the same value. """ - def max(self): """Returns a tuple of the max result with its key""" - def median(self): """Returns a tuple of the median result with its key""" - def min(self): """Returns a tuple of the min result with its key""" - def sort_by_node(self, reverse=True): """ Sorts by node id in ascending or descending order. @@ -67,7 +57,6 @@ class AlgorithmResult: Returns: A sorted list of tuples containing node names and values. """ - def sort_by_node_name(self, reverse=True): """ The function `sort_by_node_name` sorts a vector of tuples containing a node and an optional @@ -81,7 +70,6 @@ class AlgorithmResult: Returns: The function sort_by_node_name returns a vector of tuples. Each tuple contains a Node and value """ - def sort_by_value(self, reverse=True): """ Sorts the `AlgorithmResult` by its values in ascending or descending order. @@ -92,7 +80,6 @@ class AlgorithmResult: Returns: A sorted vector of tuples containing keys of type `H` and values of type `Y`. """ - def to_df(self): """ Creates a dataframe from the result @@ -100,10 +87,8 @@ class AlgorithmResult: Returns: A `pandas.DataFrame` containing the result """ - def to_string(self): """Returns a formatted string representation of the algorithm.""" - def top_k(self, k, percentage=False, reverse=True): """ Retrieves the top-k elements from the `AlgorithmResult` based on its values. @@ -125,14 +110,12 @@ class ConstProperties: def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def as_dict(self): """ as_dict() -> dict[str, Any] convert the properties view to a python dict """ - def get(self, key): """ get(key: str) -> Any | None @@ -142,21 +125,18 @@ class ConstProperties: get property value by key (returns `None` if key does not exist) """ - def items(self): """ items() -> list[tuple[str, Any]] lists the property keys together with the corresponding value """ - def keys(self): """ keys() -> list[str] lists the available property keys """ - def values(self): """ values() -> list[Any] @@ -164,6 +144,34 @@ class ConstProperties: lists the property values """ +class DiskGraphStorage: + def __init__(self): + """Initialize self. See help(type(self)) for accurate signature.""" + def graph_dir(self): ... + @staticmethod + def load_from_dir(graph_dir): ... + @staticmethod + def load_from_pandas(graph_dir, edge_df, time_col, src_col, dst_col): ... + @staticmethod + def load_from_parquets( + graph_dir, + layer_parquet_cols, + node_properties, + chunk_size, + t_props_chunk_size, + read_chunk_size, + concurrent_files, + num_threads, + node_type_col, + ): ... + def merge_by_sorted_gids(self, other, graph_dir): + """ + Merge this graph with another `DiskGraph`. Note that both graphs should have nodes that are + sorted by their global ids or the resulting graph will be nonsense! + """ + def to_events(self): ... + def to_persistent(self): ... + class Edge: """ PyEdge is a Python class that represents an edge in the graph. @@ -172,7 +180,6 @@ class Edge: def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def after(self, start): """ Create a view of the Edge including all events after `start` (exclusive). @@ -183,7 +190,6 @@ class Edge: Returns: A Edge object. """ - def at(self, time): """ Create a view of the Edge including all events at `time`. @@ -194,7 +200,6 @@ class Edge: Returns: A Edge object. """ - def before(self, end): """ Create a view of the Edge including all events before `end` (exclusive). @@ -205,7 +210,6 @@ class Edge: Returns: A Edge object. """ - @property def date_time(self): """ @@ -214,14 +218,12 @@ class Edge: Returns: (datetime) the datetime of an exploded edge """ - def default_layer(self): """ Return a view of Edge containing only the default edge layer Returns: Edge: The layered view """ - def deletions(self): """ Returns a list of timestamps of when an edge is deleted @@ -229,7 +231,6 @@ class Edge: Returns: A list of unix timestamps """ - def deletions_data_time(self): """ Returns a list of timestamps of when an edge is deleted @@ -237,11 +238,9 @@ class Edge: Returns: A list of DateTime objects """ - @property def dst(self): """Returns the destination node of the edge.""" - @property def earliest_date_time(self): """ @@ -250,7 +249,6 @@ class Edge: Returns: the earliest datetime of an edge """ - @property def earliest_time(self): """ @@ -259,7 +257,6 @@ class Edge: Returns: (int) The earliest time of an edge """ - @property def end(self): """ @@ -268,7 +265,6 @@ class Edge: Returns: The latest time that this Edge is valid or None if the Edge is valid for all times. """ - @property def end_date_time(self): """ @@ -277,7 +273,6 @@ class Edge: Returns: The latest datetime that this Edge is valid or None if the Edge is valid for all times. """ - def exclude_layer(self, name): """ Return a view of Edge containing all layers except the excluded `name` @@ -289,7 +284,6 @@ class Edge: Returns: Edge: The layered view """ - def exclude_layers(self, names): """ Return a view of Edge containing all layers except the excluded `names` @@ -301,7 +295,6 @@ class Edge: Returns: Edge: The layered view """ - def exclude_valid_layer(self, name): """ Return a view of Edge containing all layers except the excluded `name` @@ -311,7 +304,6 @@ class Edge: Returns: Edge: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of Edge containing all layers except the excluded `names` @@ -321,7 +313,6 @@ class Edge: Returns: Edge: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -334,16 +325,11 @@ class Edge: Returns: A `WindowSet` object. """ - def explode(self): """Explodes an edge and returns all instances it had been updated as seperate edges""" - - def explode_layers(self): - ... - + def explode_layers(self): ... def has_layer(self, name): - """ Check if Edge has the layer `"name"`""" - + """Check if Edge has the layer `"name"`""" def history(self): """ Returns a list of timestamps of when an edge is added or change to an edge is made. @@ -352,7 +338,6 @@ class Edge: A list of unix timestamps. """ - def history_date_time(self): """ Returns a list of timestamps of when an edge is added or change to an edge is made. @@ -361,20 +346,15 @@ class Edge: A list of timestamps. """ - @property def id(self): """The id of the edge.""" - def is_deleted(self): """Check if the edge is currently deleted""" - def is_self_loop(self): """Check if the edge is on the same node""" - def is_valid(self): """Check if the edge is currently valid (i.e., not deleted)""" - @property def latest_date_time(self): """ @@ -383,7 +363,6 @@ class Edge: Returns: (datetime) the latest datetime of an edge """ - @property def latest_time(self): """ @@ -392,7 +371,6 @@ class Edge: Returns: (int) The latest time of an edge """ - def layer(self, name): """ Return a view of Edge containing the layer `"name"` @@ -401,7 +379,6 @@ class Edge: Returns: Edge: The layered view """ - @property def layer_name(self): """ @@ -410,7 +387,6 @@ class Edge: Returns: (List) The name of the layer """ - @property def layer_names(self): """ @@ -419,7 +395,6 @@ class Edge: Returns: (List) The name of the layer """ - def layers(self, names): """ Return a view of Edge containing all layers `names` @@ -431,11 +406,9 @@ class Edge: Returns: Edge: The layered view """ - @property def nbr(self): """Returns the node at the other end of the edge (same as `dst()` for out-edges and `src()` for in-edges)""" - @property def properties(self): """ @@ -444,7 +417,6 @@ class Edge: Returns: Properties on the Edge. """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -458,7 +430,6 @@ class Edge: Returns: A `WindowSet` object. """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -468,7 +439,6 @@ class Edge: Returns: A Edge object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -479,7 +449,6 @@ class Edge: Returns: A Edge object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -487,11 +456,9 @@ class Edge: Arguments: """ - @property def src(self): """Returns the source node of the edge.""" - @property def start(self): """ @@ -500,7 +467,6 @@ class Edge: Returns: The earliest time that this Edge is valid or None if the Edge is valid for all times. """ - @property def start_date_time(self): """ @@ -509,7 +475,6 @@ class Edge: Returns: The earliest datetime that this Edge is valid or None if the Edge is valid for all times. """ - @property def time(self): """ @@ -518,7 +483,6 @@ class Edge: Returns: (int) The time of an exploded edge """ - def valid_layers(self, names): """ Return a view of Edge containing all layers `names` @@ -530,7 +494,6 @@ class Edge: Returns: Edge: The layered view """ - def window(self, start, end): """ Create a view of the Edge including all events between `start` (inclusive) and `end` (exclusive) @@ -542,17 +505,15 @@ class Edge: Returns: r A Edge object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this Edge""" + """Get the window size (difference between start and end) for this Edge""" class Edges: """A list of edges that can be iterated over.""" def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def after(self, start): """ Create a view of the Edges including all events after `start` (exclusive). @@ -563,7 +524,6 @@ class Edges: Returns: A Edges object. """ - def at(self, time): """ Create a view of the Edges including all events at `time`. @@ -574,7 +534,6 @@ class Edges: Returns: A Edges object. """ - def before(self, end): """ Create a view of the Edges including all events before `end` (exclusive). @@ -585,7 +544,6 @@ class Edges: Returns: A Edges object. """ - def collect(self): """ Collect all edges into a list @@ -593,10 +551,8 @@ class Edges: Returns: list[Edge]: the list of edges """ - def count(self): """Returns the number of edges""" - @property def date_time(self): """ @@ -605,14 +561,12 @@ class Edges: Returns: A list of date times. """ - def default_layer(self): """ Return a view of Edges containing only the default edge layer Returns: Edges: The layered view """ - def deletions(self): """ Returns all timestamps of edges where an edge is deleted @@ -620,7 +574,6 @@ class Edges: Returns: A list of lists of unix timestamps """ - def deletions_date_time(self): """ Returns all timestamps of edges where an edge is deleted @@ -628,11 +581,9 @@ class Edges: Returns: A list of lists of DateTime objects """ - @property def dst(self): """Returns the destination node of the edge.""" - @property def earliest_date_time(self): """ @@ -641,7 +592,6 @@ class Edges: Returns: Earliest date time of the edges. """ - @property def earliest_time(self): """ @@ -650,7 +600,6 @@ class Edges: Returns: Earliest time of the edges. """ - @property def end(self): """ @@ -659,7 +608,6 @@ class Edges: Returns: The latest time that this Edges is valid or None if the Edges is valid for all times. """ - @property def end_date_time(self): """ @@ -668,7 +616,6 @@ class Edges: Returns: The latest datetime that this Edges is valid or None if the Edges is valid for all times. """ - def exclude_layer(self, name): """ Return a view of Edges containing all layers except the excluded `name` @@ -680,7 +627,6 @@ class Edges: Returns: Edges: The layered view """ - def exclude_layers(self, names): """ Return a view of Edges containing all layers except the excluded `names` @@ -692,7 +638,6 @@ class Edges: Returns: Edges: The layered view """ - def exclude_valid_layer(self, name): """ Return a view of Edges containing all layers except the excluded `name` @@ -702,7 +647,6 @@ class Edges: Returns: Edges: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of Edges containing all layers except the excluded `names` @@ -712,7 +656,6 @@ class Edges: Returns: Edges: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -725,16 +668,11 @@ class Edges: Returns: A `WindowSet` object. """ - def explode(self): """Explodes an edge and returns all instances it had been updated as seperate edges""" - - def explode_layers(self): - ... - + def explode_layers(self): ... def has_layer(self, name): - """ Check if Edges has the layer `"name"`""" - + """Check if Edges has the layer `"name"`""" def history(self): """ Returns all timestamps of edges, when an edge is added or change to an edge is made. @@ -743,7 +681,6 @@ class Edges: A list of lists unix timestamps. """ - def history_date_time(self): """ Returns all timestamps of edges, when an edge is added or change to an edge is made. @@ -752,20 +689,15 @@ class Edges: A list of lists of timestamps. """ - @property def id(self): """Returns all ids of the edges.""" - def is_deleted(self): """Check if the edges are deleted""" - def is_self_loop(self): """Check if the edges are on the same node""" - def is_valid(self): """Check if the edges are valid (i.e. not deleted)""" - @property def latest_date_time(self): """ @@ -774,7 +706,6 @@ class Edges: Returns: Latest date time of the edges. """ - @property def latest_time(self): """ @@ -783,7 +714,6 @@ class Edges: Returns: Latest time of the edges. """ - def layer(self, name): """ Return a view of Edges containing the layer `"name"` @@ -792,7 +722,6 @@ class Edges: Returns: Edges: The layered view """ - @property def layer_name(self): """ @@ -801,7 +730,6 @@ class Edges: Returns: The name of the layer """ - @property def layer_names(self): """ @@ -810,7 +738,6 @@ class Edges: Returns: A list of layer names """ - def layers(self, names): """ Return a view of Edges containing all layers `names` @@ -822,15 +749,12 @@ class Edges: Returns: Edges: The layered view """ - @property def nbr(self): """Returns the node at the other end of the edge (same as `dst()` for out-edges and `src()` for in-edges)""" - @property def properties(self): """Returns all properties of the edges""" - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -844,7 +768,6 @@ class Edges: Returns: A `WindowSet` object. """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -854,7 +777,6 @@ class Edges: Returns: A Edges object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -865,7 +787,6 @@ class Edges: Returns: A Edges object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -873,11 +794,9 @@ class Edges: Arguments: """ - @property def src(self): """Returns the source node of the edge.""" - @property def start(self): """ @@ -886,7 +805,6 @@ class Edges: Returns: The earliest time that this Edges is valid or None if the Edges is valid for all times. """ - @property def start_date_time(self): """ @@ -895,7 +813,6 @@ class Edges: Returns: The earliest datetime that this Edges is valid or None if the Edges is valid for all times. """ - @property def time(self): """ @@ -904,8 +821,9 @@ class Edges: Returns: Time of edge """ - - def to_df(self, include_property_history=True, convert_datetime=False, explode=False): + def to_df( + self, include_property_history=True, convert_datetime=False, explode=False + ): """ Converts the graph's edges into a Pandas DataFrame. @@ -924,7 +842,6 @@ class Edges: Returns: If successful, this PyObject will be a Pandas DataFrame. """ - def valid_layers(self, names): """ Return a view of Edges containing all layers `names` @@ -936,7 +853,6 @@ class Edges: Returns: Edges: The layered view """ - def window(self, start, end): """ Create a view of the Edges including all events between `start` (inclusive) and `end` (exclusive) @@ -948,17 +864,15 @@ class Edges: Returns: r A Edges object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this Edges""" + """Get the window size (difference between start and end) for this Edges""" class Graph: """A temporal graph.""" def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def add_constant_properties(self, properties): """ Adds static properties to the graph. @@ -969,7 +883,6 @@ class Graph: Returns: None """ - def add_edge(self, timestamp, src, dst, properties=None, layer=None): """ Adds a new edge with the given source and destination nodes and properties to the graph. @@ -984,7 +897,6 @@ class Graph: Returns: None """ - def add_node(self, timestamp, id, properties=None, node_type=None): """ Adds a new node with the given id and properties to the graph. @@ -997,7 +909,6 @@ class Graph: Returns: None """ - def add_property(self, timestamp, properties): """ Adds properties to the graph. @@ -1009,7 +920,6 @@ class Graph: Returns: None """ - def after(self, start): """ Create a view of the GraphView including all events after `start` (exclusive). @@ -1020,7 +930,6 @@ class Graph: Returns: A GraphView object. """ - def at(self, time): """ Create a view of the GraphView including all events at `time`. @@ -1031,7 +940,6 @@ class Graph: Returns: A GraphView object. """ - def before(self, end): """ Create a view of the GraphView including all events before `end` (exclusive). @@ -1042,18 +950,8 @@ class Graph: Returns: A GraphView object. """ - - def cache(self, path): - """ - Write Graph to cache file and initialise the cache. - - Future updates are tracked. Use `write_updates` to persist them to the - cache file. If the file already exists its contents are overwritten. - - Arguments: - path (str): The path to the cache file - """ - + def bincode(self): + """Get bincode encoded graph""" def count_edges(self): """ Number of edges in the graph @@ -1061,7 +959,6 @@ class Graph: Returns: the number of edges in the graph """ - def count_nodes(self): """ Number of nodes in the graph @@ -1069,7 +966,6 @@ class Graph: Returns: the number of nodes in the graph """ - def count_temporal_edges(self): """ Number of edges in the graph @@ -1077,26 +973,12 @@ class Graph: Returns: the number of temporal edges in the graph """ - def default_layer(self): """ Return a view of GraphView containing only the default edge layer Returns: GraphView: The layered view """ - - @staticmethod - def deserialise(bytes): - """ - Load Graph from serialised bytes. - - Arguments: - bytes (Bytes): The serialised bytes to decode - - Returns: - Graph - """ - @property def earliest_date_time(self): """ @@ -1105,7 +987,6 @@ class Graph: Returns: the datetime of the earliest activity in the graph """ - @property def earliest_time(self): """ @@ -1114,7 +995,6 @@ class Graph: Returns: the timestamp of the earliest activity in the graph """ - def edge(self, src, dst): """ Gets the edge with the specified source and destination nodes @@ -1126,7 +1006,6 @@ class Graph: Returns: the edge with the specified source and destination nodes, or None if the edge does not exist """ - @property def edges(self): """ @@ -1135,7 +1014,6 @@ class Graph: Returns: the edges in the graph """ - @property def end(self): """ @@ -1144,7 +1022,6 @@ class Graph: Returns: The latest time that this GraphView is valid or None if the GraphView is valid for all times. """ - @property def end_date_time(self): """ @@ -1153,7 +1030,6 @@ class Graph: Returns: The latest datetime that this GraphView is valid or None if the GraphView is valid for all times. """ - def exclude_layer(self, name): """ Return a view of GraphView containing all layers except the excluded `name` @@ -1165,7 +1041,6 @@ class Graph: Returns: GraphView: The layered view """ - def exclude_layers(self, names): """ Return a view of GraphView containing all layers except the excluded `names` @@ -1177,7 +1052,6 @@ class Graph: Returns: GraphView: The layered view """ - def exclude_nodes(self, nodes): """ Returns a subgraph given a set of nodes that are excluded from the subgraph @@ -1188,7 +1062,6 @@ class Graph: Returns: GraphView - Returns the subgraph """ - def exclude_valid_layer(self, name): """ Return a view of GraphView containing all layers except the excluded `name` @@ -1198,7 +1071,6 @@ class Graph: Returns: GraphView: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of GraphView containing all layers except the excluded `names` @@ -1208,7 +1080,6 @@ class Graph: Returns: GraphView: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -1221,7 +1092,6 @@ class Graph: Returns: A `WindowSet` object. """ - def find_edges(self, properties_dict): """ Get the edges that match the properties name and value @@ -1230,7 +1100,6 @@ class Graph: Returns: the edges that match the properties name and value """ - def find_nodes(self, properties_dict): """ Get the nodes that match the properties name and value @@ -1239,7 +1108,9 @@ class Graph: Returns: the nodes that match the properties name and value """ - + @staticmethod + def from_bincode(bytes): + """Creates a graph from a bincode encoded graph""" def get_all_node_types(self): """ Returns all the node types in the graph. @@ -1247,7 +1118,6 @@ class Graph: Returns: A list of node types """ - def has_edge(self, src, dst): """ Returns true if the graph contains the specified edge @@ -1259,10 +1129,8 @@ class Graph: Returns: true if the graph contains the specified edge, false otherwise """ - def has_layer(self, name): - """ Check if GraphView has the layer `"name"`""" - + """Check if GraphView has the layer `"name"`""" def has_node(self, id): """ Returns true if the graph contains the specified node @@ -1273,7 +1141,6 @@ class Graph: Returns: true if the graph contains the specified node, false otherwise """ - def import_edge(self, edge, force=False): """ Import a single edge into the graph. @@ -1289,7 +1156,6 @@ class Graph: Returns: Result, GraphError> - A Result object which is Ok if the edge was successfully imported, and Err otherwise. """ - def import_edges(self, edges, force=False): """ Import multiple edges into the graph. @@ -1303,7 +1169,6 @@ class Graph: force (boolean) - An optional boolean flag indicating whether to force the import of the edges. """ - def import_node(self, node, force=False): """ Import a single node into the graph. @@ -1318,7 +1183,6 @@ class Graph: Returns: Result, GraphError> - A Result object which is Ok if the node was successfully imported, and Err otherwise. """ - def import_nodes(self, nodes, force=False): """ Import multiple nodes into the graph. @@ -1332,7 +1196,6 @@ class Graph: force (boolean) - An optional boolean flag indicating whether to force the import of the nodes. """ - def index(self): """ Indexes all node and edge properties. @@ -1342,7 +1205,6 @@ class Graph: Returns: GraphIndex - Returns a GraphIndex """ - def largest_connected_component(self): """ Gives the large connected component of a graph. @@ -1354,7 +1216,6 @@ class Graph: A raphtory graph, which essentially is a sub-graph of the graph `g` """ - @property def latest_date_time(self): """ @@ -1363,7 +1224,6 @@ class Graph: Returns: the datetime of the latest activity in the graph """ - @property def latest_time(self): """ @@ -1372,7 +1232,6 @@ class Graph: Returns: the timestamp of the latest activity in the graph """ - def layer(self, name): """ Return a view of GraphView containing the layer `"name"` @@ -1381,7 +1240,6 @@ class Graph: Returns: GraphView: The layered view """ - def layers(self, names): """ Return a view of GraphView containing all layers `names` @@ -1393,23 +1251,16 @@ class Graph: Returns: GraphView: The layered view """ - - @staticmethod - def load_cached(path): - """ - Load Graph from a file and initialise it as a cache file. - - Future updates are tracked. Use `write_updates` to persist them to the - cache file. - - Arguments: - path (str): The path to the cache file - - Returns: - Graph - """ - - def load_edge_props_from_pandas(self, df, src, dst, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + def load_edge_props_from_pandas( + self, + df, + src, + dst, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edge properties from a Pandas DataFrame. @@ -1417,16 +1268,27 @@ class Graph: df (Dataframe): The Pandas DataFrame containing edge information. src (str): The column name for the source node. dst (str): The column name for the destination node. - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): Layer name. Defaults to None. (optional) - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the data frame or if it should be used directly as the layer for all edges (optional) defaults to True. + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): The edge layer name (optional) Defaults to None. + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_edge_props_from_parquet(self, parquet_path, src, dst, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + Raises: + GraphError: If the operation fails. + """ + def load_edge_props_from_parquet( + self, + parquet_path, + src, + dst, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edge properties from parquet file @@ -1434,183 +1296,200 @@ class Graph: parquet_path (str): Parquet file or directory of Parquet files path containing edge information. src (str): The column name for the source node. dst (str): The column name for the destination node. - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): Layer name. Defaults to None. (optional) - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the data frame or if it should be used directly as the layer for all edges (optional) defaults to True. + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): The edge layer name (optional) Defaults to None. + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_edges_from_pandas(self, df, src, dst, time, properties=None, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + Raises: + GraphError: If the operation fails. + """ + def load_edges_from_pandas( + self, + df, + time, + src, + dst, + properties=None, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edges from a Pandas DataFrame into the graph. Arguments: df (Dataframe): The Pandas DataFrame containing the edges. + time (str): The column name for the update timestamps. src (str): The column name for the source node ids. dst (str): The column name for the destination node ids. - time (str): The column name for the update timestamps. - properties (List): List of edge property column names. Defaults to None. (optional) - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the dateframe or if it should be used directly as the layer for all edges (optional) defaults to True. - - Returns: - Result<(), GraphError>: Result of the operation. - """ - - def load_edges_from_parquet(self, parquet_path, src, dst, time, properties=None, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + properties (List[str]): List of edge property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): A constant value to use as the layer for all edges (optional) Defaults to None. (cannot be used in combination with layer_col) + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. (cannot be used in combination with layer) + Returns: + None: If the operation is successful. + + Raises: + GraphError: If the operation fails. + """ + def load_edges_from_parquet( + self, + parquet_path, + time, + src, + dst, + properties=None, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edges from a Parquet file into the graph. Arguments: parquet_path (str): Parquet file or directory of Parquet files path containing edges + time (str): The column name for the update timestamps. src (str): The column name for the source node ids. dst (str): The column name for the destination node ids. - time (str): The column name for the update timestamps. - properties (List): List of edge property column names. Defaults to None. (optional) - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the dataframe or if it should be used directly as the layer for all edges (optional) defaults to True. - + properties (List[str]): List of edge property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): A constant value to use as the layer for all edges (optional) Defaults to None. (cannot be used in combination with layer_col) + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. (cannot be used in combination with layer) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. + Raises: + GraphError: If the operation fails. + """ @staticmethod - def load_from_file(path): + def load_from_file(path, force=False): """ - Load Graph from a file. + Loads a graph from the given path. Arguments: - path (str): The path to the file. + path (str): The path to the graph. Returns: - Graph - """ - - @staticmethod - def load_from_pandas(edge_df, edge_src, edge_dst, edge_time, edge_properties=None, edge_const_properties=None, edge_shared_const_properties=None, edge_layer=None, layer_in_df=True, node_df=None, node_id=None, node_time=None, node_properties=None, node_const_properties=None, node_shared_const_properties=None, node_type=None, node_type_in_df=True): - """ - Load a graph from a Pandas DataFrame. - - Args: - edge_df (pandas.DataFrame): The DataFrame containing the edges. - edge_src (str): The column name for the source node ids. - edge_dst (str): The column name for the destination node ids. - edge_time (str): The column name for the timestamps. - edge_properties (list): The column names for the temporal properties (optional) Defaults to None. - edge_const_properties (list): The column names for the constant properties (optional) Defaults to None. - edge_shared_const_properties (dict): A dictionary of constant properties that will be added to every edge (optional) Defaults to None. - edge_layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the edge_df or if it should be used directly as the layer for all edges (optional) defaults to True. - node_df (pandas.DataFrame): The DataFrame containing the nodes (optional) Defaults to None. - node_id (str): The column name for the node ids (optional) Defaults to None. - node_time (str): The column name for the node timestamps (optional) Defaults to None. - node_properties (list): The column names for the node temporal properties (optional) Defaults to None. - node_const_properties (list): The column names for the node constant properties (optional) Defaults to None. - node_shared_const_properties (dict): A dictionary of constant properties that will be added to every node (optional) Defaults to None. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - - Returns: - Graph: The loaded Graph object. + Graph: The loaded graph. """ - - @staticmethod - def load_from_parquet(edge_parquet_path, edge_src, edge_dst, edge_time, edge_properties=None, edge_const_properties=None, edge_shared_const_properties=None, edge_layer=None, layer_in_df=True, node_parquet_path=None, node_id=None, node_time=None, node_properties=None, node_const_properties=None, node_shared_const_properties=None, node_type=None, node_type_in_df=True): - """ - Load a graph from Parquet file. - - Args: - edge_parquet_path (str): Parquet file or directory of Parquet files containing the edges. - edge_src (str): The column name for the source node ids. - edge_dst (str): The column name for the destination node ids. - edge_time (str): The column name for the timestamps. - edge_properties (list): The column names for the temporal properties (optional) Defaults to None. - edge_const_properties (list): The column names for the constant properties (optional) Defaults to None. - edge_shared_const_properties (dict): A dictionary of constant properties that will be added to every edge (optional) Defaults to None. - edge_layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the edge_df or if it should be used directly as the layer for all edges (optional) defaults to True. - node_parquet_path (str): Parquet file or directory of Parquet files containing the nodes (optional) Defaults to None. - node_id (str): The column name for the node ids (optional) Defaults to None. - node_time (str): The column name for the node timestamps (optional) Defaults to None. - node_properties (list): The column names for the node temporal properties (optional) Defaults to None. - node_const_properties (list): The column names for the node constant properties (optional) Defaults to None. - node_shared_const_properties (dict): A dictionary of constant properties that will be added to every node (optional) Defaults to None. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - - Returns: - Graph: The loaded Graph object. - """ - - def load_node_props_from_pandas(self, df, id, const_properties=None, shared_const_properties=None): + def load_node_props_from_pandas( + self, + df, + id, + node_type=None, + node_type_col=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load node properties from a Pandas DataFrame. Arguments: df (Dataframe): The Pandas DataFrame containing node information. id(str): The column name for the node IDs. - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (>): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_node_props_from_parquet(self, parquet_path, id, const_properties=None, shared_const_properties=None): + Raises: + GraphError: If the operation fails. + """ + def load_node_props_from_parquet( + self, + parquet_path, + id, + node_type=None, + node_type_col=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load node properties from a parquet file. Arguments: parquet_path (str): Parquet file or directory of Parquet files path containing node information. id(str): The column name for the node IDs. - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (>): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_nodes_from_pandas(self, df, id, time, node_type=None, node_type_in_df=True, properties=None, const_properties=None, shared_const_properties=None): + Raises: + GraphError: If the operation fails. + """ + def load_nodes_from_pandas( + self, + df, + time, + id, + node_type=None, + node_type_col=None, + properties=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load nodes from a Pandas DataFrame into the graph. Arguments: df (pandas.DataFrame): The Pandas DataFrame containing the nodes. - id (str): The column name for the node IDs. time (str): The column name for the timestamps. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - properties (List): List of node property column names. Defaults to None. (optional) - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (Dictionary/Hashmap of properties): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) - Returns: - Result<(), GraphError>: Result of the operation. - """ - - def load_nodes_from_parquet(self, parquet_path, id, time, node_type=None, node_type_in_df=True, properties=None, const_properties=None, shared_const_properties=None): + id (str): The column name for the node IDs. + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + properties (List[str]): List of node property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + Returns: + None: If the operation is successful. + + Raises: + GraphError: If the operation fails. + """ + def load_nodes_from_parquet( + self, + parquet_path, + time, + id, + node_type=None, + node_type_col=None, + properties=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load nodes from a Parquet file into the graph. Arguments: parquet_path (str): Parquet file or directory of Parquet files containing the nodes - id (str): The column name for the node IDs. time (str): The column name for the timestamps. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - properties (List): List of node property column names. Defaults to None. (optional) - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (Dictionary/Hashmap of properties): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + id (str): The column name for the node IDs. + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + properties (List[str]): List of node property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. + Raises: + GraphError: If the operation fails. + """ def materialize(self): """ Returns a 'materialized' clone of the graph view - i.e. a new graph with a copy of the data seen within the view instead of just a mask over the original graph @@ -1618,7 +1497,6 @@ class Graph: Returns: GraphView - Returns a graph clone """ - def node(self, id): """ Gets the node with the specified id @@ -1629,7 +1507,6 @@ class Graph: Returns: the node with the specified id, or None if the node does not exist """ - @property def nodes(self): """ @@ -1638,10 +1515,10 @@ class Graph: Returns: the nodes in the graph """ - + def persist_as_disk_graph(self, graph_dir): + """save graph in disk_graph format and memory map the result""" def persistent_graph(self): """Get persistent graph""" - @property def properties(self): """ @@ -1651,7 +1528,6 @@ class Graph: Returns: HashMap - Properties paired with their names """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -1665,23 +1541,16 @@ class Graph: Returns: A `WindowSet` object. """ - def save_to_file(self, path): """ - Saves the Graph to the given path. + Saves the graph to the given path. Arguments: - path (str): The path to the file. - """ - - def serialise(self): - """ - Serialise Graph to bytes. + path (str): The path to the graph. Returns: - Bytes + None """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -1691,7 +1560,6 @@ class Graph: Returns: A GraphView object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -1702,7 +1570,6 @@ class Graph: Returns: A GraphView object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -1710,7 +1577,6 @@ class Graph: Arguments: """ - @property def start(self): """ @@ -1719,7 +1585,6 @@ class Graph: Returns: The earliest time that this GraphView is valid or None if the GraphView is valid for all times. """ - @property def start_date_time(self): """ @@ -1728,7 +1593,6 @@ class Graph: Returns: The earliest datetime that this GraphView is valid or None if the GraphView is valid for all times. """ - def subgraph(self, nodes): """ Returns a subgraph given a set of nodes @@ -1739,7 +1603,6 @@ class Graph: Returns: GraphView - Returns the subgraph """ - def subgraph_node_types(self, node_types): """ Returns a subgraph filtered by node types given a set of node types @@ -1750,8 +1613,15 @@ class Graph: Returns: GraphView - Returns the subgraph """ - - def to_networkx(self, explode_edges=False, include_node_properties=True, include_edge_properties=True, include_update_history=True, include_property_history=True): + def to_disk_graph(self, graph_dir): ... + def to_networkx( + self, + explode_edges=False, + include_node_properties=True, + include_edge_properties=True, + include_update_history=True, + include_property_history=True, + ): """ Returns a graph with NetworkX. @@ -1769,8 +1639,18 @@ class Graph: Returns: A Networkx MultiDiGraph. """ - - def to_pyvis(self, explode_edges=False, edge_color="#000000", shape=None, node_image=None, edge_weight=None, edge_label=None, colour_nodes_by_type=False, notebook=False, **kwargs): + def to_pyvis( + self, + explode_edges=False, + edge_color="#000000", + shape=None, + node_image=None, + edge_weight=None, + edge_label=None, + colour_nodes_by_type=False, + notebook=False, + **kwargs + ): """ Draw a graph with PyVis. Pyvis is a required dependency. If you intend to use this function make sure that you install Pyvis @@ -1794,11 +1674,9 @@ class Graph: Returns: A pyvis network """ - @property def unique_layers(self): """Return all the layer ids in the graph""" - def update_constant_properties(self, properties): """ Updates static properties to the graph. @@ -1809,7 +1687,6 @@ class Graph: Returns: None """ - def valid_layers(self, names): """ Return a view of GraphView containing all layers `names` @@ -1821,8 +1698,16 @@ class Graph: Returns: GraphView: The layered view """ - - def vectorise(self, embedding, cache=None, overwrite_cache=False, graph_document=None, node_document=None, edge_document=None, verbose=False): + def vectorise( + self, + embedding, + cache=None, + overwrite_cache=False, + graph_document=None, + node_document=None, + edge_document=None, + verbose=False, + ): """ Create a VectorisedGraph from the current graph @@ -1837,7 +1722,6 @@ class Graph: Returns: A VectorisedGraph with all the documents/embeddings computed and with an initial empty selection """ - def window(self, start, end): """ Create a view of the GraphView including all events between `start` (inclusive) and `end` (exclusive) @@ -1849,13 +1733,9 @@ class Graph: Returns: r A GraphView object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this GraphView""" - - def write_updates(self): - """Persist the new updates by appending them to the cache file.""" + """Get the window size (difference between start and end) for this GraphView""" class GraphIndex: """ @@ -1866,8 +1746,9 @@ class GraphIndex: def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - - def fuzzy_search_edges(self, query, limit=25, offset=0, prefix=False, levenshtein_distance=0): + def fuzzy_search_edges( + self, query, limit=25, offset=0, prefix=False, levenshtein_distance=0 + ): """ Searches for edges which match the given query. This uses Tantivy's fuzzy search. @@ -1881,8 +1762,9 @@ class GraphIndex: Returns: A list of edges which match the query. The list will be empty if no edges match the query. """ - - def fuzzy_search_nodes(self, query, limit=25, offset=0, prefix=False, levenshtein_distance=0): + def fuzzy_search_nodes( + self, query, limit=25, offset=0, prefix=False, levenshtein_distance=0 + ): """ Searches for nodes which match the given query. This uses Tantivy's fuzzy search. If you would like to better understand the query syntax, please visit our documentation at https://docs.raphtory.com @@ -1897,7 +1779,6 @@ class GraphIndex: Returns: A list of nodes which match the query. The list will be empty if no nodes match. """ - def search_edges(self, query, limit=25, offset=0): """ Searches for edges which match the given query. This uses Tantivy's exact search. @@ -1910,7 +1791,6 @@ class GraphIndex: Returns: A list of edges which match the query. The list will be empty if no edges match the query. """ - def search_nodes(self, query, limit=25, offset=0): """ Searches for nodes which match the given query. This uses Tantivy's exact search. @@ -1925,10 +1805,8 @@ class GraphIndex: """ class MutableEdge: - def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def add_constant_properties(self, properties, layer=None): """ Add constant properties to an edge in the graph. @@ -1944,7 +1822,6 @@ class MutableEdge: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def add_updates(self, t, properties=None, layer=None): """ Add updates to an edge in the graph at a specified time. @@ -1959,7 +1836,6 @@ class MutableEdge: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def after(self, start): """ Create a view of the Edge including all events after `start` (exclusive). @@ -1970,7 +1846,6 @@ class MutableEdge: Returns: A Edge object. """ - def at(self, time): """ Create a view of the Edge including all events at `time`. @@ -1981,7 +1856,6 @@ class MutableEdge: Returns: A Edge object. """ - def before(self, end): """ Create a view of the Edge including all events before `end` (exclusive). @@ -1992,7 +1866,6 @@ class MutableEdge: Returns: A Edge object. """ - @property def date_time(self): """ @@ -2001,14 +1874,12 @@ class MutableEdge: Returns: (datetime) the datetime of an exploded edge """ - def default_layer(self): """ Return a view of Edge containing only the default edge layer Returns: Edge: The layered view """ - def deletions(self): """ Returns a list of timestamps of when an edge is deleted @@ -2016,7 +1887,6 @@ class MutableEdge: Returns: A list of unix timestamps """ - def deletions_data_time(self): """ Returns a list of timestamps of when an edge is deleted @@ -2024,11 +1894,9 @@ class MutableEdge: Returns: A list of DateTime objects """ - @property def dst(self): """Returns the destination node of the edge.""" - @property def earliest_date_time(self): """ @@ -2037,7 +1905,6 @@ class MutableEdge: Returns: the earliest datetime of an edge """ - @property def earliest_time(self): """ @@ -2046,7 +1913,6 @@ class MutableEdge: Returns: (int) The earliest time of an edge """ - @property def end(self): """ @@ -2055,7 +1921,6 @@ class MutableEdge: Returns: The latest time that this Edge is valid or None if the Edge is valid for all times. """ - @property def end_date_time(self): """ @@ -2064,7 +1929,6 @@ class MutableEdge: Returns: The latest datetime that this Edge is valid or None if the Edge is valid for all times. """ - def exclude_layer(self, name): """ Return a view of Edge containing all layers except the excluded `name` @@ -2076,7 +1940,6 @@ class MutableEdge: Returns: Edge: The layered view """ - def exclude_layers(self, names): """ Return a view of Edge containing all layers except the excluded `names` @@ -2088,7 +1951,6 @@ class MutableEdge: Returns: Edge: The layered view """ - def exclude_valid_layer(self, name): """ Return a view of Edge containing all layers except the excluded `name` @@ -2098,7 +1960,6 @@ class MutableEdge: Returns: Edge: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of Edge containing all layers except the excluded `names` @@ -2108,7 +1969,6 @@ class MutableEdge: Returns: Edge: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -2121,16 +1981,11 @@ class MutableEdge: Returns: A `WindowSet` object. """ - def explode(self): """Explodes an edge and returns all instances it had been updated as seperate edges""" - - def explode_layers(self): - ... - + def explode_layers(self): ... def has_layer(self, name): - """ Check if Edge has the layer `"name"`""" - + """Check if Edge has the layer `"name"`""" def history(self): """ Returns a list of timestamps of when an edge is added or change to an edge is made. @@ -2139,7 +1994,6 @@ class MutableEdge: A list of unix timestamps. """ - def history_date_time(self): """ Returns a list of timestamps of when an edge is added or change to an edge is made. @@ -2148,20 +2002,15 @@ class MutableEdge: A list of timestamps. """ - @property def id(self): """The id of the edge.""" - def is_deleted(self): """Check if the edge is currently deleted""" - def is_self_loop(self): """Check if the edge is on the same node""" - def is_valid(self): """Check if the edge is currently valid (i.e., not deleted)""" - @property def latest_date_time(self): """ @@ -2170,7 +2019,6 @@ class MutableEdge: Returns: (datetime) the latest datetime of an edge """ - @property def latest_time(self): """ @@ -2179,7 +2027,6 @@ class MutableEdge: Returns: (int) The latest time of an edge """ - def layer(self, name): """ Return a view of Edge containing the layer `"name"` @@ -2188,7 +2035,6 @@ class MutableEdge: Returns: Edge: The layered view """ - @property def layer_name(self): """ @@ -2197,7 +2043,6 @@ class MutableEdge: Returns: (List) The name of the layer """ - @property def layer_names(self): """ @@ -2206,7 +2051,6 @@ class MutableEdge: Returns: (List) The name of the layer """ - def layers(self, names): """ Return a view of Edge containing all layers `names` @@ -2218,11 +2062,9 @@ class MutableEdge: Returns: Edge: The layered view """ - @property def nbr(self): """Returns the node at the other end of the edge (same as `dst()` for out-edges and `src()` for in-edges)""" - @property def properties(self): """ @@ -2231,7 +2073,6 @@ class MutableEdge: Returns: Properties on the Edge. """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -2245,7 +2086,6 @@ class MutableEdge: Returns: A `WindowSet` object. """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -2255,7 +2095,6 @@ class MutableEdge: Returns: A Edge object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -2266,7 +2105,6 @@ class MutableEdge: Returns: A Edge object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -2274,11 +2112,9 @@ class MutableEdge: Arguments: """ - @property def src(self): """Returns the source node of the edge.""" - @property def start(self): """ @@ -2287,7 +2123,6 @@ class MutableEdge: Returns: The earliest time that this Edge is valid or None if the Edge is valid for all times. """ - @property def start_date_time(self): """ @@ -2296,7 +2131,6 @@ class MutableEdge: Returns: The earliest datetime that this Edge is valid or None if the Edge is valid for all times. """ - @property def time(self): """ @@ -2305,7 +2139,6 @@ class MutableEdge: Returns: (int) The time of an exploded edge """ - def update_constant_properties(self, properties, layer=None): """ Update constant properties of an edge in the graph overwriting existing values. @@ -2321,7 +2154,6 @@ class MutableEdge: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def valid_layers(self, names): """ Return a view of Edge containing all layers `names` @@ -2333,7 +2165,6 @@ class MutableEdge: Returns: Edge: The layered view """ - def window(self, start, end): """ Create a view of the Edge including all events between `start` (inclusive) and `end` (exclusive) @@ -2345,16 +2176,13 @@ class MutableEdge: Returns: r A Edge object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this Edge""" + """Get the window size (difference between start and end) for this Edge""" class MutableNode: - def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def add_constant_properties(self, properties): """ Add constant properties to a node in the graph. @@ -2369,7 +2197,6 @@ class MutableNode: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def add_updates(self, t, properties=None): """ Add updates to a node in the graph at a specified time. @@ -2384,7 +2211,6 @@ class MutableNode: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def after(self, start): """ Create a view of the Node including all events after `start` (exclusive). @@ -2395,7 +2221,6 @@ class MutableNode: Returns: A Node object. """ - def at(self, time): """ Create a view of the Node including all events at `time`. @@ -2406,7 +2231,6 @@ class MutableNode: Returns: A Node object. """ - def before(self, end): """ Create a view of the Node including all events before `end` (exclusive). @@ -2417,14 +2241,12 @@ class MutableNode: Returns: A Node object. """ - def default_layer(self): """ Return a view of Node containing only the default edge layer Returns: Node: The layered view """ - def degree(self): """ Get the degree of this node (i.e., the number of edges that are incident to it). @@ -2432,7 +2254,6 @@ class MutableNode: Returns The degree of this node. """ - @property def earliest_date_time(self): """ @@ -2441,7 +2262,6 @@ class MutableNode: Returns: The earliest datetime that the node exists as an integer. """ - @property def earliest_time(self): """ @@ -2450,7 +2270,6 @@ class MutableNode: Returns: The earliest time that the node exists as an integer. """ - @property def edges(self): """ @@ -2460,7 +2279,6 @@ class MutableNode: An iterator over the edges that are incident to this node. """ - @property def end(self): """ @@ -2469,7 +2287,6 @@ class MutableNode: Returns: The latest time that this Node is valid or None if the Node is valid for all times. """ - @property def end_date_time(self): """ @@ -2478,7 +2295,6 @@ class MutableNode: Returns: The latest datetime that this Node is valid or None if the Node is valid for all times. """ - def exclude_layer(self, name): """ Return a view of Node containing all layers except the excluded `name` @@ -2490,7 +2306,6 @@ class MutableNode: Returns: Node: The layered view """ - def exclude_layers(self, names): """ Return a view of Node containing all layers except the excluded `names` @@ -2502,7 +2317,6 @@ class MutableNode: Returns: Node: The layered view """ - def exclude_valid_layer(self, name): """ Return a view of Node containing all layers except the excluded `name` @@ -2512,7 +2326,6 @@ class MutableNode: Returns: Node: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of Node containing all layers except the excluded `names` @@ -2522,7 +2335,6 @@ class MutableNode: Returns: Node: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -2535,10 +2347,8 @@ class MutableNode: Returns: A `WindowSet` object. """ - def has_layer(self, name): - """ Check if Node has the layer `"name"`""" - + """Check if Node has the layer `"name"`""" def history(self): """ Returns the history of a node, including node additions and changes made to node. @@ -2546,7 +2356,6 @@ class MutableNode: Returns: A list of unix timestamps of the event history of node. """ - def history_date_time(self): """ Returns the history of a node, including node additions and changes made to node. @@ -2555,7 +2364,6 @@ class MutableNode: A list of timestamps of the event history of node. """ - @property def id(self): """ @@ -2565,7 +2373,6 @@ class MutableNode: Returns: The id of the node as an integer. """ - def in_degree(self): """ Get the in-degree of this node (i.e., the number of edges that are incident to it from other nodes). @@ -2573,7 +2380,6 @@ class MutableNode: Returns: The in-degree of this node. """ - @property def in_edges(self): """ @@ -2583,7 +2389,6 @@ class MutableNode: An iterator over the edges that point into this node. """ - @property def in_neighbours(self): """ @@ -2593,7 +2398,6 @@ class MutableNode: An iterator over the neighbours of this node that point into this node. """ - @property def latest_date_time(self): """ @@ -2605,7 +2409,6 @@ class MutableNode: Returns: The latest datetime that the node exists as an integer. """ - @property def latest_time(self): """ @@ -2614,7 +2417,6 @@ class MutableNode: Returns: The latest time that the node exists as an integer. """ - def layer(self, name): """ Return a view of Node containing the layer `"name"` @@ -2623,7 +2425,6 @@ class MutableNode: Returns: Node: The layered view """ - def layers(self, names): """ Return a view of Node containing all layers `names` @@ -2635,7 +2436,6 @@ class MutableNode: Returns: Node: The layered view """ - @property def name(self): """ @@ -2644,7 +2444,6 @@ class MutableNode: Returns: The name of the node as a string. """ - @property def neighbours(self): """ @@ -2654,11 +2453,9 @@ class MutableNode: An iterator over the neighbours of this node. """ - @property def node_type(self): """Returns the type of node""" - def out_degree(self): """ Get the out-degree of this node (i.e., the number of edges that are incident to it from this node). @@ -2666,7 +2463,6 @@ class MutableNode: Returns: The out-degree of this node. """ - @property def out_edges(self): """ @@ -2676,7 +2472,6 @@ class MutableNode: An iterator over the edges that point out of this node. """ - @property def out_neighbours(self): """ @@ -2686,7 +2481,6 @@ class MutableNode: An iterator over the neighbours of this node that point out of this node. """ - @property def properties(self): """ @@ -2695,7 +2489,6 @@ class MutableNode: Returns: A list of properties. """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -2709,7 +2502,6 @@ class MutableNode: Returns: A `WindowSet` object. """ - def set_node_type(self, new_type): """ Set the type on the node. This only works if the type has not been previously set, otherwise will @@ -2721,7 +2513,6 @@ class MutableNode: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -2731,7 +2522,6 @@ class MutableNode: Returns: A Node object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -2742,7 +2532,6 @@ class MutableNode: Returns: A Node object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -2750,7 +2539,6 @@ class MutableNode: Arguments: """ - @property def start(self): """ @@ -2759,7 +2547,6 @@ class MutableNode: Returns: The earliest time that this Node is valid or None if the Node is valid for all times. """ - @property def start_date_time(self): """ @@ -2768,7 +2555,6 @@ class MutableNode: Returns: The earliest datetime that this Node is valid or None if the Node is valid for all times. """ - def update_constant_properties(self, properties): """ Update constant properties of a node in the graph overwriting existing values. @@ -2783,7 +2569,6 @@ class MutableNode: Returns: Result: A result object indicating success or failure. On failure, it contains a GraphError. """ - def valid_layers(self, names): """ Return a view of Node containing all layers `names` @@ -2795,7 +2580,6 @@ class MutableNode: Returns: Node: The layered view """ - def window(self, start, end): """ Create a view of the Node including all events between `start` (inclusive) and `end` (exclusive) @@ -2807,17 +2591,15 @@ class MutableNode: Returns: r A Node object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this Node""" + """Get the window size (difference between start and end) for this Node""" class Node: """A node (or node) in the graph.""" def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def after(self, start): """ Create a view of the Node including all events after `start` (exclusive). @@ -2828,7 +2610,6 @@ class Node: Returns: A Node object. """ - def at(self, time): """ Create a view of the Node including all events at `time`. @@ -2839,7 +2620,6 @@ class Node: Returns: A Node object. """ - def before(self, end): """ Create a view of the Node including all events before `end` (exclusive). @@ -2850,14 +2630,12 @@ class Node: Returns: A Node object. """ - def default_layer(self): """ Return a view of Node containing only the default edge layer Returns: Node: The layered view """ - def degree(self): """ Get the degree of this node (i.e., the number of edges that are incident to it). @@ -2865,7 +2643,6 @@ class Node: Returns The degree of this node. """ - @property def earliest_date_time(self): """ @@ -2874,7 +2651,6 @@ class Node: Returns: The earliest datetime that the node exists as an integer. """ - @property def earliest_time(self): """ @@ -2883,7 +2659,6 @@ class Node: Returns: The earliest time that the node exists as an integer. """ - @property def edges(self): """ @@ -2893,7 +2668,6 @@ class Node: An iterator over the edges that are incident to this node. """ - @property def end(self): """ @@ -2902,7 +2676,6 @@ class Node: Returns: The latest time that this Node is valid or None if the Node is valid for all times. """ - @property def end_date_time(self): """ @@ -2911,7 +2684,6 @@ class Node: Returns: The latest datetime that this Node is valid or None if the Node is valid for all times. """ - def exclude_layer(self, name): """ Return a view of Node containing all layers except the excluded `name` @@ -2923,7 +2695,6 @@ class Node: Returns: Node: The layered view """ - def exclude_layers(self, names): """ Return a view of Node containing all layers except the excluded `names` @@ -2935,7 +2706,6 @@ class Node: Returns: Node: The layered view """ - def exclude_valid_layer(self, name): """ Return a view of Node containing all layers except the excluded `name` @@ -2945,7 +2715,6 @@ class Node: Returns: Node: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of Node containing all layers except the excluded `names` @@ -2955,7 +2724,6 @@ class Node: Returns: Node: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -2968,10 +2736,8 @@ class Node: Returns: A `WindowSet` object. """ - def has_layer(self, name): - """ Check if Node has the layer `"name"`""" - + """Check if Node has the layer `"name"`""" def history(self): """ Returns the history of a node, including node additions and changes made to node. @@ -2979,7 +2745,6 @@ class Node: Returns: A list of unix timestamps of the event history of node. """ - def history_date_time(self): """ Returns the history of a node, including node additions and changes made to node. @@ -2988,7 +2753,6 @@ class Node: A list of timestamps of the event history of node. """ - @property def id(self): """ @@ -2998,7 +2762,6 @@ class Node: Returns: The id of the node as an integer. """ - def in_degree(self): """ Get the in-degree of this node (i.e., the number of edges that are incident to it from other nodes). @@ -3006,7 +2769,6 @@ class Node: Returns: The in-degree of this node. """ - @property def in_edges(self): """ @@ -3016,7 +2778,6 @@ class Node: An iterator over the edges that point into this node. """ - @property def in_neighbours(self): """ @@ -3026,7 +2787,6 @@ class Node: An iterator over the neighbours of this node that point into this node. """ - @property def latest_date_time(self): """ @@ -3038,7 +2798,6 @@ class Node: Returns: The latest datetime that the node exists as an integer. """ - @property def latest_time(self): """ @@ -3047,7 +2806,6 @@ class Node: Returns: The latest time that the node exists as an integer. """ - def layer(self, name): """ Return a view of Node containing the layer `"name"` @@ -3056,7 +2814,6 @@ class Node: Returns: Node: The layered view """ - def layers(self, names): """ Return a view of Node containing all layers `names` @@ -3068,7 +2825,6 @@ class Node: Returns: Node: The layered view """ - @property def name(self): """ @@ -3077,7 +2833,6 @@ class Node: Returns: The name of the node as a string. """ - @property def neighbours(self): """ @@ -3087,11 +2842,9 @@ class Node: An iterator over the neighbours of this node. """ - @property def node_type(self): """Returns the type of node""" - def out_degree(self): """ Get the out-degree of this node (i.e., the number of edges that are incident to it from this node). @@ -3099,7 +2852,6 @@ class Node: Returns: The out-degree of this node. """ - @property def out_edges(self): """ @@ -3109,7 +2861,6 @@ class Node: An iterator over the edges that point out of this node. """ - @property def out_neighbours(self): """ @@ -3119,7 +2870,6 @@ class Node: An iterator over the neighbours of this node that point out of this node. """ - @property def properties(self): """ @@ -3128,7 +2878,6 @@ class Node: Returns: A list of properties. """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -3142,7 +2891,6 @@ class Node: Returns: A `WindowSet` object. """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -3152,7 +2900,6 @@ class Node: Returns: A Node object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -3163,7 +2910,6 @@ class Node: Returns: A Node object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -3171,7 +2917,6 @@ class Node: Arguments: """ - @property def start(self): """ @@ -3180,7 +2925,6 @@ class Node: Returns: The earliest time that this Node is valid or None if the Node is valid for all times. """ - @property def start_date_time(self): """ @@ -3189,7 +2933,6 @@ class Node: Returns: The earliest datetime that this Node is valid or None if the Node is valid for all times. """ - def valid_layers(self, names): """ Return a view of Node containing all layers `names` @@ -3201,7 +2944,6 @@ class Node: Returns: Node: The layered view """ - def window(self, start, end): """ Create a view of the Node including all events between `start` (inclusive) and `end` (exclusive) @@ -3213,17 +2955,15 @@ class Node: Returns: r A Node object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this Node""" + """Get the window size (difference between start and end) for this Node""" class Nodes: """A list of nodes that can be iterated over.""" def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def after(self, start): """ Create a view of the Nodes including all events after `start` (exclusive). @@ -3234,7 +2974,6 @@ class Nodes: Returns: A Nodes object. """ - def at(self, time): """ Create a view of the Nodes including all events at `time`. @@ -3245,7 +2984,6 @@ class Nodes: Returns: A Nodes object. """ - def before(self, end): """ Create a view of the Nodes including all events before `end` (exclusive). @@ -3256,7 +2994,6 @@ class Nodes: Returns: A Nodes object. """ - def collect(self): """ Collect all nodes into a list @@ -3264,14 +3001,12 @@ class Nodes: Returns: list[Node]: the list of nodes """ - def default_layer(self): """ Return a view of Nodes containing only the default edge layer Returns: Nodes: The layered view """ - def degree(self): """ Returns the number of edges of the nodes @@ -3279,7 +3014,6 @@ class Nodes: Returns: An iterator of the number of edges of the nodes """ - @property def earliest_date_time(self): """ @@ -3288,11 +3022,9 @@ class Nodes: Returns: Earliest time of the nodes. """ - @property def earliest_time(self): """Returns an iterator over the nodes earliest time""" - @property def edges(self): """ @@ -3302,7 +3034,6 @@ class Nodes: An iterator over the edges that are incident to this node. """ - @property def end(self): """ @@ -3311,7 +3042,6 @@ class Nodes: Returns: The latest time that this Nodes is valid or None if the Nodes is valid for all times. """ - @property def end_date_time(self): """ @@ -3320,7 +3050,6 @@ class Nodes: Returns: The latest datetime that this Nodes is valid or None if the Nodes is valid for all times. """ - def exclude_layer(self, name): """ Return a view of Nodes containing all layers except the excluded `name` @@ -3332,7 +3061,6 @@ class Nodes: Returns: Nodes: The layered view """ - def exclude_layers(self, names): """ Return a view of Nodes containing all layers except the excluded `names` @@ -3344,7 +3072,6 @@ class Nodes: Returns: Nodes: The layered view """ - def exclude_valid_layer(self, name): """ Return a view of Nodes containing all layers except the excluded `name` @@ -3354,7 +3081,6 @@ class Nodes: Returns: Nodes: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of Nodes containing all layers except the excluded `names` @@ -3364,7 +3090,6 @@ class Nodes: Returns: Nodes: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -3377,10 +3102,8 @@ class Nodes: Returns: A `WindowSet` object. """ - def has_layer(self, name): - """ Check if Nodes has the layer `"name"`""" - + """Check if Nodes has the layer `"name"`""" def history(self): """ Returns all timestamps of nodes, when an node is added or change to an node is made. @@ -3389,7 +3112,6 @@ class Nodes: A list of unix timestamps. """ - def history_date_time(self): """ Returns all timestamps of nodes, when an node is added or change to an node is made. @@ -3398,11 +3120,9 @@ class Nodes: An list of timestamps. """ - @property def id(self): """Returns an iterator over the nodes ids""" - def in_degree(self): """ Returns the number of in edges of the nodes @@ -3410,7 +3130,6 @@ class Nodes: Returns: An iterator of the number of in edges of the nodes """ - @property def in_edges(self): """ @@ -3420,7 +3139,6 @@ class Nodes: An iterator over the edges that point into this node. """ - @property def in_neighbours(self): """ @@ -3430,7 +3148,6 @@ class Nodes: An iterator over the neighbours of this node that point into this node. """ - @property def latest_date_time(self): """ @@ -3439,11 +3156,9 @@ class Nodes: Returns: Latest date time of the nodes. """ - @property def latest_time(self): """Returns an iterator over the nodes latest time""" - def layer(self, name): """ Return a view of Nodes containing the layer `"name"` @@ -3452,7 +3167,6 @@ class Nodes: Returns: Nodes: The layered view """ - def layers(self, names): """ Return a view of Nodes containing all layers `names` @@ -3464,11 +3178,9 @@ class Nodes: Returns: Nodes: The layered view """ - @property def name(self): """Returns an iterator over the nodes name""" - @property def neighbours(self): """ @@ -3478,11 +3190,9 @@ class Nodes: An iterator over the neighbours of this node. """ - @property def node_type(self): """Returns the type of node""" - def out_degree(self): """ Returns the number of out edges of the nodes @@ -3490,7 +3200,6 @@ class Nodes: Returns: An iterator of the number of out edges of the nodes """ - @property def out_edges(self): """ @@ -3500,7 +3209,6 @@ class Nodes: An iterator over the edges that point out of this node. """ - @property def out_neighbours(self): """ @@ -3510,7 +3218,6 @@ class Nodes: An iterator over the neighbours of this node that point out of this node. """ - @property def properties(self): """ @@ -3519,7 +3226,6 @@ class Nodes: Returns: A List of properties """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -3533,7 +3239,6 @@ class Nodes: Returns: A `WindowSet` object. """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -3543,7 +3248,6 @@ class Nodes: Returns: A Nodes object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -3554,7 +3258,6 @@ class Nodes: Returns: A Nodes object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -3562,7 +3265,6 @@ class Nodes: Arguments: """ - @property def start(self): """ @@ -3571,7 +3273,6 @@ class Nodes: Returns: The earliest time that this Nodes is valid or None if the Nodes is valid for all times. """ - @property def start_date_time(self): """ @@ -3580,7 +3281,6 @@ class Nodes: Returns: The earliest datetime that this Nodes is valid or None if the Nodes is valid for all times. """ - def to_df(self, include_property_history=False, convert_datetime=False): """ Converts the graph's nodes into a Pandas DataFrame. @@ -3597,10 +3297,7 @@ class Nodes: Returns: If successful, this PyObject will be a Pandas DataFrame. """ - - def type_filter(self, node_types): - ... - + def type_filter(self, node_types): ... def valid_layers(self, names): """ Return a view of Nodes containing all layers `names` @@ -3612,7 +3309,6 @@ class Nodes: Returns: Nodes: The layered view """ - def window(self, start, end): """ Create a view of the Nodes including all events between `start` (inclusive) and `end` (exclusive) @@ -3624,17 +3320,15 @@ class Nodes: Returns: r A Nodes object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this Nodes""" + """Get the window size (difference between start and end) for this Nodes""" class PersistentGraph: """A temporal graph that allows edges and nodes to be deleted.""" def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def add_constant_properties(self, properties): """ Adds static properties to the graph. @@ -3645,7 +3339,6 @@ class PersistentGraph: Returns: None """ - def add_edge(self, timestamp, src, dst, properties=None, layer=None): """ Adds a new edge with the given source and destination nodes and properties to the graph. @@ -3660,7 +3353,6 @@ class PersistentGraph: Returns: None """ - def add_node(self, timestamp, id, properties=None, node_type=None): """ Adds a new node with the given id and properties to the graph. @@ -3674,7 +3366,6 @@ class PersistentGraph: Returns: None """ - def add_property(self, timestamp, properties): """ Adds properties to the graph. @@ -3686,7 +3377,6 @@ class PersistentGraph: Returns: None """ - def after(self, start): """ Create a view of the GraphView including all events after `start` (exclusive). @@ -3697,7 +3387,6 @@ class PersistentGraph: Returns: A GraphView object. """ - def at(self, time): """ Create a view of the GraphView including all events at `time`. @@ -3708,7 +3397,6 @@ class PersistentGraph: Returns: A GraphView object. """ - def before(self, end): """ Create a view of the GraphView including all events before `end` (exclusive). @@ -3719,18 +3407,8 @@ class PersistentGraph: Returns: A GraphView object. """ - - def cache(self, path): - """ - Write PersistentGraph to cache file and initialise the cache. - - Future updates are tracked. Use `write_updates` to persist them to the - cache file. If the file already exists its contents are overwritten. - - Arguments: - path (str): The path to the cache file - """ - + def bincode(self): + """Get bincode encoded graph""" def count_edges(self): """ Number of edges in the graph @@ -3738,7 +3416,6 @@ class PersistentGraph: Returns: the number of edges in the graph """ - def count_nodes(self): """ Number of nodes in the graph @@ -3746,7 +3423,6 @@ class PersistentGraph: Returns: the number of nodes in the graph """ - def count_temporal_edges(self): """ Number of edges in the graph @@ -3754,14 +3430,12 @@ class PersistentGraph: Returns: the number of temporal edges in the graph """ - def default_layer(self): """ Return a view of GraphView containing only the default edge layer Returns: GraphView: The layered view """ - def delete_edge(self, timestamp, src, dst, layer=None): """ Deletes an edge given the timestamp, src and dst nodes and layer (optional) @@ -3775,19 +3449,6 @@ class PersistentGraph: Returns: None or a GraphError if the edge could not be deleted """ - - @staticmethod - def deserialise(bytes): - """ - Load PersistentGraph from serialised bytes. - - Arguments: - bytes (Bytes): The serialised bytes to decode - - Returns: - PersistentGraph - """ - @property def earliest_date_time(self): """ @@ -3796,7 +3457,6 @@ class PersistentGraph: Returns: the datetime of the earliest activity in the graph """ - @property def earliest_time(self): """ @@ -3805,7 +3465,6 @@ class PersistentGraph: Returns: the timestamp of the earliest activity in the graph """ - def edge(self, src, dst): """ Gets the edge with the specified source and destination nodes @@ -3817,7 +3476,6 @@ class PersistentGraph: Returns: the edge with the specified source and destination nodes, or None if the edge does not exist """ - @property def edges(self): """ @@ -3826,7 +3484,6 @@ class PersistentGraph: Returns: the edges in the graph """ - @property def end(self): """ @@ -3835,7 +3492,6 @@ class PersistentGraph: Returns: The latest time that this GraphView is valid or None if the GraphView is valid for all times. """ - @property def end_date_time(self): """ @@ -3844,10 +3500,8 @@ class PersistentGraph: Returns: The latest datetime that this GraphView is valid or None if the GraphView is valid for all times. """ - def event_graph(self): """Get event graph""" - def exclude_layer(self, name): """ Return a view of GraphView containing all layers except the excluded `name` @@ -3859,7 +3513,6 @@ class PersistentGraph: Returns: GraphView: The layered view """ - def exclude_layers(self, names): """ Return a view of GraphView containing all layers except the excluded `names` @@ -3871,7 +3524,6 @@ class PersistentGraph: Returns: GraphView: The layered view """ - def exclude_nodes(self, nodes): """ Returns a subgraph given a set of nodes that are excluded from the subgraph @@ -3882,7 +3534,6 @@ class PersistentGraph: Returns: GraphView - Returns the subgraph """ - def exclude_valid_layer(self, name): """ Return a view of GraphView containing all layers except the excluded `name` @@ -3892,7 +3543,6 @@ class PersistentGraph: Returns: GraphView: The layered view """ - def exclude_valid_layers(self, names): """ Return a view of GraphView containing all layers except the excluded `names` @@ -3902,7 +3552,6 @@ class PersistentGraph: Returns: GraphView: The layered view """ - def expanding(self, step): """ Creates a `WindowSet` with the given `step` size using an expanding window. @@ -3915,7 +3564,6 @@ class PersistentGraph: Returns: A `WindowSet` object. """ - def find_edges(self, properties_dict): """ Get the edges that match the properties name and value @@ -3924,7 +3572,6 @@ class PersistentGraph: Returns: the edges that match the properties name and value """ - def find_nodes(self, properties_dict): """ Get the nodes that match the properties name and value @@ -3933,7 +3580,9 @@ class PersistentGraph: Returns: the nodes that match the properties name and value """ - + @staticmethod + def from_bincode(bytes): + """Creates a graph from a bincode encoded graph""" def get_all_node_types(self): """ Returns all the node types in the graph. @@ -3941,7 +3590,6 @@ class PersistentGraph: Returns: A list of node types """ - def has_edge(self, src, dst): """ Returns true if the graph contains the specified edge @@ -3953,10 +3601,8 @@ class PersistentGraph: Returns: true if the graph contains the specified edge, false otherwise """ - def has_layer(self, name): - """ Check if GraphView has the layer `"name"`""" - + """Check if GraphView has the layer `"name"`""" def has_node(self, id): """ Returns true if the graph contains the specified node @@ -3967,7 +3613,6 @@ class PersistentGraph: Returns: true if the graph contains the specified node, false otherwise """ - def import_edge(self, edge, force=False): """ Import a single edge into the graph. @@ -3983,7 +3628,6 @@ class PersistentGraph: Returns: Result, GraphError> - A Result object which is Ok if the edge was successfully imported, and Err otherwise. """ - def import_edges(self, edges, force=False): """ Import multiple edges into the graph. @@ -3997,7 +3641,6 @@ class PersistentGraph: force (boolean) - An optional boolean flag indicating whether to force the import of the edges. """ - def import_node(self, node, force=False): """ Import a single node into the graph. @@ -4012,7 +3655,6 @@ class PersistentGraph: Returns: Result, GraphError> - A Result object which is Ok if the node was successfully imported, and Err otherwise. """ - def import_nodes(self, nodes, force=False): """ Import multiple nodes into the graph. @@ -4026,7 +3668,6 @@ class PersistentGraph: force (boolean) - An optional boolean flag indicating whether to force the import of the nodes. """ - def index(self): """ Indexes all node and edge properties. @@ -4036,7 +3677,6 @@ class PersistentGraph: Returns: GraphIndex - Returns a GraphIndex """ - @property def latest_date_time(self): """ @@ -4045,7 +3685,6 @@ class PersistentGraph: Returns: the datetime of the latest activity in the graph """ - @property def latest_time(self): """ @@ -4054,7 +3693,6 @@ class PersistentGraph: Returns: the timestamp of the latest activity in the graph """ - def layer(self, name): """ Return a view of GraphView containing the layer `"name"` @@ -4063,7 +3701,6 @@ class PersistentGraph: Returns: GraphView: The layered view """ - def layers(self, names): """ Return a view of GraphView containing all layers `names` @@ -4075,23 +3712,54 @@ class PersistentGraph: Returns: GraphView: The layered view """ - - @staticmethod - def load_cached(path): + def load_edge_deletions_from_pandas( + self, df, time, src, dst, layer=None, layer_col=None + ): """ - Load PersistentGraph from a file and initialise it as a cache file. - - Future updates are tracked. Use `write_updates` to persist them to the - cache file. + Load edges deletions from a Pandas DataFrame into the graph. Arguments: - path (str): The path to the cache file - + df (Dataframe): The Pandas DataFrame containing the edges. + time (str): The column name for the update timestamps. + src (str): The column name for the source node ids. + dst (str): The column name for the destination node ids. + layer (str): A constant value to use as the layer for all edges (optional) Defaults to None. (cannot be used in combination with layer_col) + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. (cannot be used in combination with layer) Returns: - PersistentGraph + None: If the operation is successful. + + Raises: + GraphError: If the operation fails. + """ + def load_edge_deletions_from_parquet( + self, parquet_path, time, src, dst, layer=None, layer_col=None + ): """ + Load edges deletions from a Parquet file into the graph. - def load_edge_props_from_pandas(self, df, src, dst, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + Arguments: + parquet_path (str): Parquet file or directory of Parquet files path containing node information. + src (str): The column name for the source node ids. + dst (str): The column name for the destination node ids. + time (str): The column name for the update timestamps. + layer (str): A constant value to use as the layer for all edges (optional) Defaults to None. (cannot be used in combination with layer_col) + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. (cannot be used in combination with layer) + Returns: + None: If the operation is successful. + + Raises: + GraphError: If the operation fails. + """ + def load_edge_props_from_pandas( + self, + df, + src, + dst, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edge properties from a Pandas DataFrame. @@ -4099,16 +3767,27 @@ class PersistentGraph: df (Dataframe): The Pandas DataFrame containing edge information. src (str): The column name for the source node. dst (str): The column name for the destination node. - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): Layer name. Defaults to None. (optional) - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the data frame or if it should be used directly as the layer for all edges (optional) defaults to True. + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): The edge layer name (optional) Defaults to None. + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_edge_props_from_parquet(self, parquet_path, src, dst, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + Raises: + GraphError: If the operation fails. + """ + def load_edge_props_from_parquet( + self, + parquet_path, + src, + dst, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edge properties from parquet file @@ -4116,215 +3795,200 @@ class PersistentGraph: parquet_path (str): Parquet file or directory of Parquet files path containing edge information. src (str): The column name for the source node. dst (str): The column name for the destination node. - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): Layer name. Defaults to None. (optional) - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the data frame or if it should be used directly as the layer for all edges (optional) defaults to True. - - Returns: - Result<(), GraphError>: Result of the operation. - """ - - def load_edges_deletions_from_pandas(self, df, src, dst, time, layer=None, layer_in_df=True): - """ - Load edges deletions from a Pandas DataFrame into the graph. - - Arguments: - df (Dataframe): The Pandas DataFrame containing the edges. - src (str): The column name for the source node ids. - dst (str): The column name for the destination node ids. - time (str): The column name for the update timestamps. + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the dataframe or if it should be used directly as the layer for all edges (optional) defaults to True. + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_edges_deletions_from_parquet(self, parquet_path, src, dst, time, layer=None, layer_in_df=True): + Raises: + GraphError: If the operation fails. """ - Load edges deletions from a Parquet file into the graph. - - Arguments: - parquet_path (str): Parquet file or directory of Parquet files path containing node information. - src (str): The column name for the source node ids. - dst (str): The column name for the destination node ids. - time (str): The column name for the update timestamps. - layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the dataframe or if it should be used directly as the layer for all edges (optional) defaults to True. - - Returns: - Result<(), GraphError>: Result of the operation. - """ - - def load_edges_from_pandas(self, df, src, dst, time, properties=None, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + def load_edges_from_pandas( + self, + df, + time, + src, + dst, + properties=None, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edges from a Pandas DataFrame into the graph. Arguments: df (Dataframe): The Pandas DataFrame containing the edges. + time (str): The column name for the update timestamps. src (str): The column name for the source node ids. dst (str): The column name for the destination node ids. - time (str): The column name for the update timestamps. - properties (List): List of edge property column names. Defaults to None. (optional) - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the dataframe or if it should be used directly as the layer for all edges (optional) defaults to True. - - Returns: - Result<(), GraphError>: Result of the operation. - """ - - def load_edges_from_parquet(self, parquet_path, src, dst, time, properties=None, const_properties=None, shared_const_properties=None, layer=None, layer_in_df=True): + properties (List[str]): List of edge property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): A constant value to use as the layer for all edges (optional) Defaults to None. (cannot be used in combination with layer_col) + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. (cannot be used in combination with layer) + Returns: + None: If the operation is successful. + + Raises: + GraphError: If the operation fails. + """ + def load_edges_from_parquet( + self, + parquet_path, + time, + src, + dst, + properties=None, + constant_properties=None, + shared_constant_properties=None, + layer=None, + layer_col=None, + ): """ Load edges from a Parquet file into the graph. Arguments: parquet_path (str): Parquet file or directory of Parquet files path containing edges + time (str): The column name for the update timestamps. src (str): The column name for the source node ids. dst (str): The column name for the destination node ids. - time (str): The column name for the update timestamps. - properties (List): List of edge property column names. Defaults to None. (optional) - const_properties (List): List of constant edge property column names. Defaults to None. (optional) - shared_const_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) - layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the dataframe or if it should be used directly as the layer for all edges (optional) defaults to True. - + properties (List[str]): List of edge property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant edge property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every edge. Defaults to None. (optional) + layer (str): A constant value to use as the layer for all edges (optional) Defaults to None. (cannot be used in combination with layer_col) + layer_col (str): The edge layer col name in dataframe (optional) Defaults to None. (cannot be used in combination with layer) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. + Raises: + GraphError: If the operation fails. + """ @staticmethod - def load_from_file(path): + def load_from_file(path, force=False): """ - Load PersistentGraph from a file. + Loads a graph from the given path. Arguments: - path (str): The path to the file. + path (str): The path to the graph. Returns: - PersistentGraph - """ - - @staticmethod - def load_from_pandas(edge_df, edge_src, edge_dst, edge_time, edge_properties=None, edge_const_properties=None, edge_shared_const_properties=None, edge_layer=None, layer_in_df=True, node_df=None, node_id=None, node_time=None, node_properties=None, node_const_properties=None, node_shared_const_properties=None, node_type=None, node_type_in_df=True): - """ - Load a graph from a Pandas DataFrame. - - Args: - edge_df (pandas.DataFrame): The DataFrame containing the edges. - edge_src (str): The column name for the source node ids. - edge_dst (str): The column name for the destination node ids. - edge_time (str): The column name for the timestamps. - edge_properties (list): The column names for the temporal properties (optional) Defaults to None. - edge_const_properties (list): The column names for the constant properties (optional) Defaults to None. - edge_shared_const_properties (dict): A dictionary of constant properties that will be added to every edge (optional) Defaults to None. - edge_layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the edge_df or if it should be used directly as the layer for all edges (optional) defaults to True. - node_df (pandas.DataFrame): The DataFrame containing the nodes (optional) Defaults to None. - node_id (str): The column name for the node ids (optional) Defaults to None. - node_time (str): The column name for the node timestamps (optional) Defaults to None. - node_properties (list): The column names for the node temporal properties (optional) Defaults to None. - node_const_properties (list): The column names for the node constant properties (optional) Defaults to None. - node_shared_const_properties (dict): A dictionary of constant properties that will be added to every node (optional) Defaults to None. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - - Returns: - Graph: The loaded Graph object. + Graph: The loaded graph. """ - - @staticmethod - def load_from_parquet(edge_parquet_path, edge_src, edge_dst, edge_time, edge_properties=None, edge_const_properties=None, edge_shared_const_properties=None, edge_layer=None, layer_in_df=True, node_parquet_path=None, node_id=None, node_time=None, node_properties=None, node_const_properties=None, node_shared_const_properties=None, node_type=None, node_type_in_df=True): - """ - Load a graph from Parquet file. - - Args: - edge_parquet_path (str): Parquet file or directory of Parquet files containing the edges. - edge_src (str): The column name for the source node ids. - edge_dst (str): The column name for the destination node ids. - edge_time (str): The column name for the timestamps. - edge_properties (list): The column names for the temporal properties (optional) Defaults to None. - edge_const_properties (list): The column names for the constant properties (optional) Defaults to None. - edge_shared_const_properties (dict): A dictionary of constant properties that will be added to every edge (optional) Defaults to None. - edge_layer (str): The edge layer name (optional) Defaults to None. - layer_in_df (bool): Whether the layer name should be used to look up the values in a column of the edge_df or if it should be used directly as the layer for all edges (optional) defaults to True. - node_parquet_path (str): Parquet file or directory of Parquet files containing the nodes (optional) Defaults to None. - node_id (str): The column name for the node ids (optional) Defaults to None. - node_time (str): The column name for the node timestamps (optional) Defaults to None. - node_properties (list): The column names for the node temporal properties (optional) Defaults to None. - node_const_properties (list): The column names for the node constant properties (optional) Defaults to None. - node_shared_const_properties (dict): A dictionary of constant properties that will be added to every node (optional) Defaults to None. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - - Returns: - Graph: The loaded Graph object. - """ - - def load_node_props_from_pandas(self, df, id, const_properties=None, shared_const_properties=None): + def load_node_props_from_pandas( + self, + df, + id, + node_type=None, + node_type_col=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load node properties from a Pandas DataFrame. Arguments: df (Dataframe): The Pandas DataFrame containing node information. id(str): The column name for the node IDs. - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (>): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_node_props_from_parquet(self, parquet_path, id, const_properties=None, shared_const_properties=None): + Raises: + GraphError: If the operation fails. + """ + def load_node_props_from_parquet( + self, + parquet_path, + id, + node_type=None, + node_type_col=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load node properties from a parquet file. Arguments: parquet_path (str): Parquet file or directory of Parquet files path containing node information. id(str): The column name for the node IDs. - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (>): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. - def load_nodes_from_pandas(self, df, id, time, node_type=None, node_type_in_df=True, properties=None, const_properties=None, shared_const_properties=None): + Raises: + GraphError: If the operation fails. + """ + def load_nodes_from_pandas( + self, + df, + time, + id, + node_type=None, + node_type_col=None, + properties=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load nodes from a Pandas DataFrame into the graph. Arguments: df (pandas.DataFrame): The Pandas DataFrame containing the nodes. - id (str): The column name for the node IDs. time (str): The column name for the timestamps. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - properties (List): List of node property column names. Defaults to None. (optional) - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (Dictionary/Hashmap of properties): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) - Returns: - Result<(), GraphError>: Result of the operation. - """ - - def load_nodes_from_parquet(self, parquet_path, id, time, node_type=None, node_type_in_df=True, properties=None, const_properties=None, shared_const_properties=None): + id (str): The column name for the node IDs. + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + properties (List[str]): List of node property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + Returns: + None: If the operation is successful. + + Raises: + GraphError: If the operation fails. + """ + def load_nodes_from_parquet( + self, + parquet_path, + time, + id, + node_type=None, + node_type_col=None, + properties=None, + constant_properties=None, + shared_constant_properties=None, + ): """ Load nodes from a Parquet file into the graph. Arguments: parquet_path (str): Parquet file or directory of Parquet files containing the nodes - id (str): The column name for the node IDs. time (str): The column name for the timestamps. - node_type (str): the column name for the node type - node_type_in_df (bool): whether the node type should be used to look up the values in a column of the df or if it should be used directly as the node type - properties (List): List of node property column names. Defaults to None. (optional) - const_properties (List): List of constant node property column names. Defaults to None. (optional) - shared_const_properties (Dictionary/Hashmap of properties): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) + id (str): The column name for the node IDs. + node_type (str): A constant value to use as the node type for all nodes (optional). Defaults to None. (cannot be used in combination with node_type_col) + node_type_col (str): The node type col name in dataframe (optional) Defaults to None. (cannot be used in combination with node_type) + properties (List[str]): List of node property column names. Defaults to None. (optional) + constant_properties (List[str]): List of constant node property column names. Defaults to None. (optional) + shared_constant_properties (dict): A dictionary of constant properties that will be added to every node. Defaults to None. (optional) Returns: - Result<(), GraphError>: Result of the operation. - """ + None: If the operation is successful. + Raises: + GraphError: If the operation fails. + """ def materialize(self): """ Returns a 'materialized' clone of the graph view - i.e. a new graph with a copy of the data seen within the view instead of just a mask over the original graph @@ -4332,7 +3996,6 @@ class PersistentGraph: Returns: GraphView - Returns a graph clone """ - def node(self, id): """ Gets the node with the specified id @@ -4343,7 +4006,6 @@ class PersistentGraph: Returns: the node with the specified id, or None if the node does not exist """ - @property def nodes(self): """ @@ -4352,7 +4014,6 @@ class PersistentGraph: Returns: the nodes in the graph """ - @property def properties(self): """ @@ -4362,7 +4023,6 @@ class PersistentGraph: Returns: HashMap - Properties paired with their names """ - def rolling(self, window, step=None): """ Creates a `WindowSet` with the given `window` size and optional `step` using a rolling window. @@ -4376,23 +4036,16 @@ class PersistentGraph: Returns: A `WindowSet` object. """ - def save_to_file(self, path): """ - Saves the PersistentGraph to the given path. + Saves the graph to the given path. Arguments: - path (str): The path to the file. - """ - - def serialise(self): - """ - Serialise PersistentGraph to bytes. + path (str): The path to the graph. Returns: - Bytes + None """ - def shrink_end(self, end): """ Set the end of the window to the smaller of `end` and `self.end()` @@ -4402,7 +4055,6 @@ class PersistentGraph: Returns: A GraphView object. """ - def shrink_start(self, start): """ Set the start of the window to the larger of `start` and `self.start()` @@ -4413,7 +4065,6 @@ class PersistentGraph: Returns: A GraphView object. """ - def shrink_window(self, start, end): """ Shrink both the start and end of the window (same as calling `shrink_start` followed by `shrink_end` but more efficient) @@ -4421,7 +4072,6 @@ class PersistentGraph: Arguments: """ - @property def start(self): """ @@ -4430,7 +4080,6 @@ class PersistentGraph: Returns: The earliest time that this GraphView is valid or None if the GraphView is valid for all times. """ - @property def start_date_time(self): """ @@ -4439,7 +4088,6 @@ class PersistentGraph: Returns: The earliest datetime that this GraphView is valid or None if the GraphView is valid for all times. """ - def subgraph(self, nodes): """ Returns a subgraph given a set of nodes @@ -4450,7 +4098,6 @@ class PersistentGraph: Returns: GraphView - Returns the subgraph """ - def subgraph_node_types(self, node_types): """ Returns a subgraph filtered by node types given a set of node types @@ -4461,8 +4108,14 @@ class PersistentGraph: Returns: GraphView - Returns the subgraph """ - - def to_networkx(self, explode_edges=False, include_node_properties=True, include_edge_properties=True, include_update_history=True, include_property_history=True): + def to_networkx( + self, + explode_edges=False, + include_node_properties=True, + include_edge_properties=True, + include_update_history=True, + include_property_history=True, + ): """ Returns a graph with NetworkX. @@ -4480,8 +4133,18 @@ class PersistentGraph: Returns: A Networkx MultiDiGraph. """ - - def to_pyvis(self, explode_edges=False, edge_color="#000000", shape=None, node_image=None, edge_weight=None, edge_label=None, colour_nodes_by_type=False, notebook=False, **kwargs): + def to_pyvis( + self, + explode_edges=False, + edge_color="#000000", + shape=None, + node_image=None, + edge_weight=None, + edge_label=None, + colour_nodes_by_type=False, + notebook=False, + **kwargs + ): """ Draw a graph with PyVis. Pyvis is a required dependency. If you intend to use this function make sure that you install Pyvis @@ -4505,11 +4168,9 @@ class PersistentGraph: Returns: A pyvis network """ - @property def unique_layers(self): """Return all the layer ids in the graph""" - def update_constant_properties(self, properties): """ Updates static properties to the graph. @@ -4520,7 +4181,6 @@ class PersistentGraph: Returns: None """ - def valid_layers(self, names): """ Return a view of GraphView containing all layers `names` @@ -4532,8 +4192,16 @@ class PersistentGraph: Returns: GraphView: The layered view """ - - def vectorise(self, embedding, cache=None, overwrite_cache=False, graph_document=None, node_document=None, edge_document=None, verbose=False): + def vectorise( + self, + embedding, + cache=None, + overwrite_cache=False, + graph_document=None, + node_document=None, + edge_document=None, + verbose=False, + ): """ Create a VectorisedGraph from the current graph @@ -4548,7 +4216,6 @@ class PersistentGraph: Returns: A VectorisedGraph with all the documents/embeddings computed and with an initial empty selection """ - def window(self, start, end): """ Create a view of the GraphView including all events between `start` (inclusive) and `end` (exclusive) @@ -4560,27 +4227,20 @@ class PersistentGraph: Returns: r A GraphView object. """ - @property def window_size(self): - """ Get the window size (difference between start and end) for this GraphView""" - - def write_updates(self): - """Persist the new updates by appending them to the cache file.""" + """Get the window size (difference between start and end) for this GraphView""" class Properties: """A view of the properties of an entity""" def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def as_dict(self): """Convert properties view to a dict""" - @property def constant(self): """Get a view of the constant properties (meta-data) only.""" - def get(self, key): """ Get property value. @@ -4588,17 +4248,13 @@ class Properties: First searches temporal properties and returns latest value if it exists. If not, it falls back to static properties. """ - def items(self): """Get a list of key-value pairs""" - def keys(self): """Get the names for all properties (includes temporal and static properties)""" - @property def temporal(self): """Get a view of the temporal properties only.""" - def values(self): """ Get the values of the properties @@ -4612,12 +4268,9 @@ class PyDirection: def __init__(self, direction): """Initialize self. See help(type(self)) for accurate signature.""" - - def as_str(self): - ... + def as_str(self): ... class PyGraphEncoder: - def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" @@ -4626,10 +4279,8 @@ class TemporalProp: def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def at(self, t): """Get the value of the property at time `t`""" - def average(self): """ Compute the average of all property values. Alias for mean(). @@ -4637,7 +4288,6 @@ class TemporalProp: Returns: Prop: The average of each property values, or None if count is zero. """ - def count(self): """ Count the number of properties. @@ -4645,19 +4295,14 @@ class TemporalProp: Returns: int: The number of properties. """ - def history(self): """Get the timestamps at which the property was updated""" - def history_date_time(self): """Get the timestamps at which the property was updated""" - def items(self): """List update timestamps and corresponding property values""" - def items_date_time(self): """List update timestamps and corresponding property values""" - def max(self): """ Find the maximum property value and its associated time. @@ -4665,7 +4310,6 @@ class TemporalProp: Returns: (i64, Prop): A tuple containing the time and the maximum property value. """ - def mean(self): """ Compute the mean of all property values. Alias for mean(). @@ -4673,7 +4317,6 @@ class TemporalProp: Returns: Prop: The mean of each property values, or None if count is zero. """ - def median(self): """ Compute the median of all property values. @@ -4681,7 +4324,6 @@ class TemporalProp: Returns: (i64, Prop): A tuple containing the time and the median property value, or None if empty """ - def min(self): """ Find the minimum property value and its associated time. @@ -4689,10 +4331,7 @@ class TemporalProp: Returns: (i64, Prop): A tuple containing the time and the minimum property value. """ - - def ordered_dedupe(self, latest_time): - ... - + def ordered_dedupe(self, latest_time): ... def sum(self): """ Compute the sum of all property values. @@ -4700,13 +4339,9 @@ class TemporalProp: Returns: Prop: The sum of all property values. """ - - def unique(self): - ... - + def unique(self): ... def value(self): """Get the latest value of the property""" - def values(self): """Get the property values for each update""" @@ -4715,7 +4350,6 @@ class TemporalProperties: def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - def get(self, key): """ get(key: str) -> Optional[TemporalProp] @@ -4725,7 +4359,6 @@ class TemporalProperties: Returns: the property view if it exists, otherwise `None` """ - def histories(self): """ Get the histories of all properties @@ -4733,7 +4366,6 @@ class TemporalProperties: Returns: dict[str, list[(int, Any)]]: the mapping of property keys to histories """ - def histories_date_time(self): """ Get the histories of all properties @@ -4741,13 +4373,10 @@ class TemporalProperties: Returns: dict[str, list[(datetime, Any)]]: the mapping of property keys to histories """ - def items(self): """List the property keys together with the corresponding values""" - def keys(self): """List the available property keys""" - def latest(self): """ Get the latest value of all properties @@ -4755,7 +4384,6 @@ class TemporalProperties: Returns: dict[str, Any]: the mapping of property keys to latest values """ - def values(self): """ List the values of the properties diff --git a/python/python/raphtory/algorithms/__init__.pyi b/python/python/raphtory/algorithms/__init__.pyi index ddd851779..2f5881186 100644 --- a/python/python/raphtory/algorithms/__init__.pyi +++ b/python/python/raphtory/algorithms/__init__.pyi @@ -73,6 +73,7 @@ def cohesive_fruchterman_reingold( ): """Cohesive version of `fruchterman_reingold` that adds virtual edges between isolated nodes""" +def connected_components(g): ... def degree_centrality(g, threads=None): """ Computes the degree centrality of all nodes in the graph. The values are normalized diff --git a/python/python/raphtory/graphql/__init__.pyi b/python/python/raphtory/graphql/__init__.pyi index 9eab7945b..b082a9c50 100644 --- a/python/python/raphtory/graphql/__init__.pyi +++ b/python/python/raphtory/graphql/__init__.pyi @@ -37,7 +37,6 @@ class RaphtoryClient: def __init__(self, url): """Initialize self. See help(type(self)) for accurate signature.""" - def copy_graph(self, path, new_path): """ Copy graph from a path `path` on the server to a `new_path` on the server @@ -49,7 +48,6 @@ class RaphtoryClient: Returns: Copy status as boolean """ - def delete_graph(self, path): """ Delete graph from a path `path` on the server @@ -60,7 +58,6 @@ class RaphtoryClient: Returns: Delete status as boolean """ - def is_server_online(self): """ Check if the server is online. @@ -68,7 +65,6 @@ class RaphtoryClient: Returns: Returns true if server is online otherwise false. """ - def move_graph(self, path, new_path): """ Move graph from a path `path` on the server to a `new_path` on the server @@ -91,7 +87,6 @@ class RaphtoryClient: Returns: The `data` field from the graphQL response. """ - def receive_graph(self, path): """ Receive graph from a path `path` on the server @@ -102,7 +97,6 @@ class RaphtoryClient: Returns: Graph as string """ - def send_graph(self, path, graph, overwrite=False): """ Send a graph to the server @@ -115,7 +109,6 @@ class RaphtoryClient: Returns: The `data` field from the graphQL response after executing the mutation. """ - def upload_graph(self, path, file_path, overwrite=False): """ Upload graph file from a path `file_path` on the client @@ -132,9 +125,15 @@ class RaphtoryClient: class RaphtoryServer: """A class for defining and running a Raphtory GraphQL server""" - def __init__(self, work_dir, cache_capacity=None, cache_tti_seconds=None, log_level=None, config_path=None): + def __init__( + self, + work_dir, + cache_capacity=None, + cache_tti_seconds=None, + log_level=None, + config_path=None, + ): """Initialize self. See help(type(self)) for accurate signature.""" - def run(self, port=1736, timeout_ms=...): """ Run the server until completion. @@ -142,7 +141,6 @@ class RaphtoryServer: Arguments: * `port`: the port to use (defaults to 1736). """ - def start(self, port=1736, timeout_ms=None): """ Start the server and return a handle to it. @@ -218,9 +216,6 @@ class RunningRaphtoryServer: def __init__(self): """Initialize self. See help(type(self)) for accurate signature.""" - - def get_client(self): - ... - + def get_client(self): ... def stop(self): """Stop the server and wait for it to finish""" diff --git a/python/tests/test_algorithms.py b/python/tests/test_algorithms.py index 5f671e82c..5fccc4851 100644 --- a/python/tests/test_algorithms.py +++ b/python/tests/test_algorithms.py @@ -258,7 +258,11 @@ def test_temporal_reachability(): actual = algorithms.temporally_reachable_nodes(g, 20, 11, [1, 2], [4, 5]) expected = { "1": [(11, "start")], - "2": [(11, "1"), (11, "start"), (12, "1"), ], + "2": [ + (11, "1"), + (11, "start"), + (12, "1"), + ], "3": [], "4": [(12, "2")], "5": [(13, "2")], @@ -321,12 +325,12 @@ def test_single_source_shortest_path(): "4": ["1", "4"], } assert ( - res_two.get_all_with_names() - == {"1": ["1"], "2": ["1", "2"], "3": ["1", "2", "3"], "4": ["1", "4"]} - ) or ( - res_two.get_all_with_names() - == {"1": ["1"], "3": ["1", "4", "3"], "2": ["1", "2"], "4": ["1", "4"]} - ) + res_two.get_all_with_names() + == {"1": ["1"], "2": ["1", "2"], "3": ["1", "2", "3"], "4": ["1", "4"]} + ) or ( + res_two.get_all_with_names() + == {"1": ["1"], "3": ["1", "4", "3"], "2": ["1", "2"], "4": ["1", "4"]} + ) def test_dijsktra_shortest_paths(): diff --git a/python/tests/test_graphql.py b/python/tests/test_graphql.py index 55a32d5f7..bac9f7fb7 100644 --- a/python/tests/test_graphql.py +++ b/python/tests/test_graphql.py @@ -610,7 +610,7 @@ def test_receive_graph_succeeds_if_graph_found(): received_graph = client.query(query)["receiveGraph"] decoded_bytes = base64.b64decode(received_graph) - g = Graph.deserialise(decoded_bytes); + g = Graph.deserialise(decoded_bytes) assert g.nodes.name == ["ben", "hamza", "haaroon"]