blugraph.core.io module¶
Reference page for the bluegraph.core.io module.
Collection of data structures for representing property graphs as data frames.
- class bluegraph.core.io.GraphProcessor(pgframe=None, directed=True)¶
Abstract class for a graph processor.
The provided interface allows to convert PGFrames into backend-specific graph objects and vice versa. It also allows to access nodes/edges and properties of backend-specific graph objects through its interface.
- exception ProcessorException¶
- classmethod from_graph_object(graph_object)¶
Initialize directly from the input graph object.
- get_pgframe(node_prop_types=None, edge_prop_types=None, node_filter=None, edge_filter=None)¶
Get a new pgframe object from the wrapped graph object.
- abstract neighbors(node_id)¶
Get neighors of the node.
- class bluegraph.core.io.PGFrame(nodes=None, edges=None, default_prop_type='category')¶
Class for storing typed property graphs as a collection of frames.
- exception PGFrameException¶
- abstract copy()¶
Copy the PGFrame.
- abstract edge_properties(edge_type=None, include_type=None)¶
Return a list of edge properties.
- abstract edge_types(flatten=False)¶
Return a set of edges types.
- abstract edges(typed_by=None, raw_frame=False)¶
Return a list of edges.
- export_to_gephi(prefix, node_attr_mapping, edge_attr_mapping, edge_filter=None)¶
Save the graph for Gephi import.
Saves the graph as two .csv files one with nodes (<prefix>_nodes.csv) and one with edges ( <prefix>_edges.csv). Node IDs are replaced by interger identifiers (Gephi asks for node IDs to be numerical) and entity names are added as the node property ‘Label’.
- from_jsonld(resources, include_context=True, type_handler=None, types_from_relations=True, exclude=None, only_props=False)¶
Create a PGFrame from jsonld.
- Parameters:
resources (iterable of dict) – Collection of input resources in JSON-LD format
include_context (bool, optional) – Flag indicating if the context should be included as a property. Default is True.
type_handler (func, optional) – Function to apply to the value of type (e.g. ‘@type’)
types_from_relations (bool, optional) – Flag indicating if resources with unkown types should be assigned with types from the incoming relations. Default is True
exclude (list of str, optional) – Collection of property names to exclude. Default is empty.
only_props (bool, optional) – Flag indicating if the procedure should extract only properties from the given resources.
- classmethod from_ontology(filepath=None, rdf_graph=None, format='turtle', remove_prop_uris=False)¶
Create a PandasPGFrame from ontology.
- abstract node_properties(node_type=None, include_type=None)¶
Return a list of node properties
- abstract node_types(flatten=False)¶
Return a set of node types.
- abstract nodes(typed_by=None, raw_frame=False)¶
Return a list of nodes.
- abstract number_of_edges(edge_type=None)¶
Return a number of nodes.
- abstract number_of_nodes(node_type=None)¶
Return a number of nodes.
- abstract rename_edge_properties(mapping)¶
Rename edge properties.
- abstract rename_node_properties(mapping)¶
Rename node properties.
- to_jsonld(edges_key='edges')¶
Create a JSON-LD representation of the PGFrame.
- class bluegraph.core.io.PandasPGFrame(nodes=None, edges=None, default_prop_type='category')¶
Class for storing typed PGs as a collection of pandas DataFrames.
- add_edges(edges)¶
Add edge ids to the PG frame.
- add_edges_from_df(df, source_column, target_column, edge_type=None, property_types=None)¶
Add edges from a dataframe.
- add_nodes(node_ids)¶
Add node ids to the PG frame.
- add_nodes_from_df(df, id_column, node_type=None, property_types=None)¶
Add nodes from a dataframe.
- copy()¶
Create a copy of the pgframe.
- edge_properties(edge_type=None, include_type=False)¶
Return a list of edge properties.
- edge_types(flatten=False)¶
Return a list of edges types.
- edges(typed_by=None, raw_frame=False, include_index=False, filter_props=None, rename_cols=None)¶
Return a list of edges.
- export_json(path)¶
Export to a JSON file.
- filter_edges(edges)¶
Get edges included in the input list.
- filter_nodes(nodes)¶
Get nodes included in the input list.
- classmethod from_frames(nodes, edges, node_prop_types=None, edge_prop_types=None)¶
Initialize from node/edge dataframes.
- classmethod from_json(json_data)¶
Load from a JSON dictionary.
- get_edge(s, t)¶
Get edge properties.
- get_node(n)¶
Get node properties.
- has_edge_types()¶
Return flag indicating if edges are typed.
- has_node_types()¶
Return flag indicating if nodes are typed.
- isolated_nodes()¶
Get nodes without any incident edges.
- classmethod load_json(path)¶
Load from a JSON file.
- node_properties(node_type=None, include_type=False)¶
Return a list of node properties
- node_types(flatten=False)¶
Return a list of node types.
- nodes(typed_by=None, raw_frame=False, include_index=False, filter_props=None, rename_cols=None)¶
Return a list of nodes.
- number_of_edges()¶
Return a number of nodes.
- number_of_nodes()¶
Return a number of nodes.
- remove_edges(edges_to_remove)¶
Remove edges from the graph.
- remove_isolated_nodes()¶
Remove nodes without any incident edges.
- remove_nodes(nodes_to_remove)¶
Remove nodes from the graph.
- rename_edge_properties(mapping)¶
Rename edge properties.
- rename_node_properties(mapping)¶
Rename node properties.
- subgraph(nodes=None, edges=None, remove_isolated_nodes=False)¶
Get a subgraph induced by input nodes and edges.
- to_json(node_id_key=None, node_type_key=None, edge_id_keys=None, edge_type_key=None)¶
Covert to a JSON dictionary.
- to_triples(predicate_prop='@type', include_type=True, include_literals=True)¶
Generate triples from the PGframe.
- class bluegraph.core.io.SparkPGFrame¶
Class for storing typed PGs as a collection of Spark DataFrames.