easygraph package
Subpackages
- easygraph.classes package
- Submodules
- easygraph.classes.base module
BaseHypergraph
BaseHypergraph.H
BaseHypergraph.H_e2v
BaseHypergraph.H_e2v_of_group()
BaseHypergraph.H_of_group
BaseHypergraph.H_v2e
BaseHypergraph.H_v2e_of_group()
BaseHypergraph.R_e2v
BaseHypergraph.R_e2v_of_group()
BaseHypergraph.R_v2e
BaseHypergraph.R_v2e_of_group()
BaseHypergraph.W_e
BaseHypergraph.W_e_of_group()
BaseHypergraph.W_v
BaseHypergraph.add_hyperedges()
BaseHypergraph.clear()
BaseHypergraph.clone()
BaseHypergraph.draw()
BaseHypergraph.drop_hyperedges()
BaseHypergraph.drop_hyperedges_of_group()
BaseHypergraph.e
BaseHypergraph.e2v()
BaseHypergraph.e2v_aggregation()
BaseHypergraph.e2v_aggregation_of_group()
BaseHypergraph.e2v_of_group()
BaseHypergraph.e2v_update()
BaseHypergraph.e2v_update_of_group()
BaseHypergraph.e_of_group()
BaseHypergraph.from_state_dict()
BaseHypergraph.group_names
BaseHypergraph.load()
BaseHypergraph.num_e
BaseHypergraph.num_e_of_group()
BaseHypergraph.num_groups
BaseHypergraph.num_v
BaseHypergraph.remove_hyperedges()
BaseHypergraph.save()
BaseHypergraph.smoothing()
BaseHypergraph.state_dict
BaseHypergraph.to()
BaseHypergraph.v
BaseHypergraph.v2e()
BaseHypergraph.v2e_aggregation()
BaseHypergraph.v2e_aggregation_of_group()
BaseHypergraph.v2e_of_group()
BaseHypergraph.v2e_update()
BaseHypergraph.v2e_update_of_group()
BaseHypergraph.v2v()
BaseHypergraph.v2v_of_group()
BaseHypergraph.v_weight
BaseHypergraph.vars_for_DL
load_structure()
- easygraph.classes.directed_graph module
DiGraph
DiGraph.add_edge()
DiGraph.add_edges()
DiGraph.add_edges_from()
DiGraph.add_edges_from_file()
DiGraph.add_node()
DiGraph.add_nodes()
DiGraph.add_nodes_from()
DiGraph.add_weighted_edge()
DiGraph.adj
DiGraph.adjlist_inner_dict_factory
DiGraph.adjlist_outer_dict_factory
DiGraph.all_neighbors()
DiGraph.copy()
DiGraph.cpp()
DiGraph.degree()
DiGraph.edge_attr_dict_factory
DiGraph.edges
DiGraph.ego_subgraph()
DiGraph.gnn_data_dict_factory
DiGraph.graph_attr_dict_factory
DiGraph.has_edge()
DiGraph.has_node()
DiGraph.in_degree()
DiGraph.is_directed()
DiGraph.is_multigraph()
DiGraph.name
DiGraph.nbunch_iter()
DiGraph.ndata
DiGraph.neighbors()
DiGraph.node_attr_dict_factory
DiGraph.node_dict_factory
DiGraph.nodes
DiGraph.nodes_subgraph()
DiGraph.number_of_edges()
DiGraph.number_of_nodes()
DiGraph.out_degree()
DiGraph.pred
DiGraph.predecessors()
DiGraph.remove_edge()
DiGraph.remove_edges()
DiGraph.remove_edges_from()
DiGraph.remove_node()
DiGraph.remove_nodes()
DiGraph.size()
DiGraph.successors()
DiGraph.to_index_node_graph()
DiGraphC
- easygraph.classes.directed_multigraph module
MultiDiGraph
MultiDiGraph.add_edge()
MultiDiGraph.degree
MultiDiGraph.edge_key_dict_factory
MultiDiGraph.edges
MultiDiGraph.in_degree
MultiDiGraph.in_edges
MultiDiGraph.is_directed()
MultiDiGraph.is_multigraph()
MultiDiGraph.out_degree
MultiDiGraph.out_edges
MultiDiGraph.remove_edge()
MultiDiGraph.reverse()
MultiDiGraph.to_undirected()
- easygraph.classes.graph module
Graph
Graph.A
Graph.D_v
Graph.D_v_neg_1_2
Graph.L_GCN
Graph.N_v()
Graph.add_edge()
Graph.add_edges()
Graph.add_edges_from()
Graph.add_edges_from_file()
Graph.add_extra_selfloop()
Graph.add_node()
Graph.add_nodes()
Graph.add_nodes_from()
Graph.add_weighted_edge()
Graph.add_weighted_edges_from()
Graph.adj
Graph.adjlist_inner_dict_factory
Graph.adjlist_outer_dict_factory
Graph.all_neighbors()
Graph.clone()
Graph.copy()
Graph.cpp()
Graph.degree()
Graph.e
Graph.e_both_side
Graph.edge_attr_dict_factory
Graph.edges
Graph.ego_subgraph()
Graph.from_hypergraph_hypergcn()
Graph.gnn_data_dict_factory
Graph.graph_attr_dict_factory
Graph.has_edge()
Graph.has_node()
Graph.is_directed()
Graph.is_multigraph()
Graph.name
Graph.nbr_v()
Graph.nbunch_iter()
Graph.ndata
Graph.neighbors()
Graph.node2index
Graph.node_attr_dict_factory
Graph.node_dict_factory
Graph.node_index
Graph.node_index_dict
Graph.nodes
Graph.nodes_subgraph()
Graph.number_of_edges()
Graph.number_of_nodes()
Graph.order()
Graph.raw_selfloop_dict
Graph.remove_edge()
Graph.remove_edges()
Graph.remove_extra_selfloop()
Graph.remove_node()
Graph.remove_nodes()
Graph.remove_nodes_from()
Graph.remove_selfloop()
Graph.size()
Graph.smoothing_with_GCN()
Graph.to_directed()
Graph.to_directed_class()
Graph.to_index_node_graph()
GraphC
- easygraph.classes.graphviews module
- easygraph.classes.hypergraph module
Hypergraph
Hypergraph.D_e
Hypergraph.D_e_neg_1
Hypergraph.D_e_neg_1_of_group()
Hypergraph.D_e_of_group()
Hypergraph.D_v
Hypergraph.D_v_neg_1
Hypergraph.D_v_neg_1_2
Hypergraph.D_v_neg_1_2_of_group()
Hypergraph.D_v_neg_1_of_group()
Hypergraph.D_v_of_group()
Hypergraph.H
Hypergraph.H_T
Hypergraph.H_T_of_group()
Hypergraph.H_of_group()
Hypergraph.L_HGNN
Hypergraph.L_HGNN_of_group()
Hypergraph.L_rw
Hypergraph.L_rw_of_group()
Hypergraph.L_sym
Hypergraph.L_sym_of_group()
Hypergraph.N_e()
Hypergraph.N_e_of_group()
Hypergraph.N_v()
Hypergraph.N_v_of_group()
Hypergraph.W_e
Hypergraph.W_e_of_group()
Hypergraph.add_hyperedges()
Hypergraph.add_hyperedges_from_feature_kNN()
Hypergraph.add_hyperedges_from_graph()
Hypergraph.add_hyperedges_from_graph_kHop()
Hypergraph.clear()
Hypergraph.clone()
Hypergraph.deg_e
Hypergraph.deg_e_of_group()
Hypergraph.deg_v
Hypergraph.deg_v_of_group()
Hypergraph.draw()
Hypergraph.drop_hyperedges()
Hypergraph.drop_hyperedges_of_group()
Hypergraph.e
Hypergraph.e2v()
Hypergraph.e2v_aggregation()
Hypergraph.e2v_aggregation_of_group()
Hypergraph.e2v_dst
Hypergraph.e2v_dst_of_group()
Hypergraph.e2v_of_group()
Hypergraph.e2v_src
Hypergraph.e2v_src_of_group()
Hypergraph.e2v_update()
Hypergraph.e2v_update_of_group()
Hypergraph.e2v_weight
Hypergraph.e2v_weight_of_group()
Hypergraph.e_of_group()
Hypergraph.from_feature_kNN()
Hypergraph.from_graph()
Hypergraph.from_graph_kHop()
Hypergraph.from_state_dict()
Hypergraph.group_names
Hypergraph.load()
Hypergraph.nbr_e()
Hypergraph.nbr_e_of_group()
Hypergraph.nbr_v()
Hypergraph.nbr_v_of_group()
Hypergraph.num_e
Hypergraph.num_e_of_group()
Hypergraph.num_groups
Hypergraph.num_v
Hypergraph.remove_group()
Hypergraph.remove_hyperedges()
Hypergraph.save()
Hypergraph.smoothing()
Hypergraph.smoothing_with_HGNN()
Hypergraph.smoothing_with_HGNN_of_group()
Hypergraph.state_dict
Hypergraph.to()
Hypergraph.v
Hypergraph.v2e()
Hypergraph.v2e_aggregation()
Hypergraph.v2e_aggregation_of_group()
Hypergraph.v2e_dst
Hypergraph.v2e_dst_of_group()
Hypergraph.v2e_of_group()
Hypergraph.v2e_src
Hypergraph.v2e_src_of_group()
Hypergraph.v2e_update()
Hypergraph.v2e_update_of_group()
Hypergraph.v2e_weight
Hypergraph.v2e_weight_of_group()
Hypergraph.v2v()
Hypergraph.v2v_of_group()
Hypergraph.vars_for_DL
- easygraph.classes.multigraph module
MultiGraph
MultiGraph.add_edge()
MultiGraph.add_edges_from()
MultiGraph.copy()
MultiGraph.degree
MultiGraph.edge_key_dict_factory
MultiGraph.edges
MultiGraph.get_edge_data()
MultiGraph.has_edge()
MultiGraph.is_directed()
MultiGraph.is_multigraph()
MultiGraph.new_edge_key()
MultiGraph.number_of_edges()
MultiGraph.remove_edge()
MultiGraph.remove_edges_from()
MultiGraph.to_directed()
- easygraph.classes.operation module
- Module contents
- easygraph.datapipe package
- easygraph.datasets package
- Subpackages
- easygraph.datasets.dynamic package
- easygraph.datasets.hypergraph package
- Submodules
- easygraph.datasets.hypergraph.House_Committees module
- easygraph.datasets.hypergraph.Yelp module
- easygraph.datasets.hypergraph.cat_edge_Cooking module
- easygraph.datasets.hypergraph.coauthorship module
- easygraph.datasets.hypergraph.cocitation module
- easygraph.datasets.hypergraph.contact_primary_school module
- easygraph.datasets.hypergraph.cooking_200 module
- easygraph.datasets.hypergraph.hypergraph_dataset_base module
- easygraph.datasets.hypergraph.loadDeepSetDatasets module
- easygraph.datasets.hypergraph.mathoverflow_answers module
- easygraph.datasets.hypergraph.senate_committees module
- easygraph.datasets.hypergraph.trivago_clicks module
- easygraph.datasets.hypergraph.walmart_trips module
- Module contents
- Submodules
- easygraph.datasets.citation_graph module
- easygraph.datasets.get_sample_graph module
- easygraph.datasets.gnn_benchmark module
- easygraph.datasets.graph_dataset_base module
- easygraph.datasets.karate module
- easygraph.datasets.ppi module
- easygraph.datasets.utils module
- Module contents
- Subpackages
- easygraph.experiments package
- easygraph.functions package
- Subpackages
- easygraph.functions.basic package
- easygraph.functions.centrality package
- Submodules
- easygraph.functions.centrality.betweenness module
- easygraph.functions.centrality.closeness module
- easygraph.functions.centrality.degree module
- easygraph.functions.centrality.ego_betweenness module
- easygraph.functions.centrality.flowbetweenness module
- easygraph.functions.centrality.laplacian module
- easygraph.functions.centrality.pagerank module
- Module contents
- easygraph.functions.community package
- Submodules
- easygraph.functions.community.LPA module
- easygraph.functions.community.ego_graph module
- easygraph.functions.community.louvain module
- easygraph.functions.community.modularity module
- easygraph.functions.community.modularity_max_detection module
- easygraph.functions.community.motif module
- Module contents
- easygraph.functions.components package
- easygraph.functions.core package
- easygraph.functions.drawing package
- Submodules
- easygraph.functions.drawing.defaults module
- easygraph.functions.drawing.drawing module
- easygraph.functions.drawing.geometry module
- easygraph.functions.drawing.layout module
- easygraph.functions.drawing.plot module
- easygraph.functions.drawing.positioning module
- easygraph.functions.drawing.simulator module
- easygraph.functions.drawing.utils module
- Module contents
- easygraph.functions.graph_embedding package
- Submodules
- easygraph.functions.graph_embedding.NOBE module
- easygraph.functions.graph_embedding.deepwalk module
- easygraph.functions.graph_embedding.line module
- easygraph.functions.graph_embedding.net_emb_example_citeseer module
- easygraph.functions.graph_embedding.node2vec module
- easygraph.functions.graph_embedding.sdne module
- Module contents
- easygraph.functions.graph_generator package
- easygraph.functions.hypergraph package
- easygraph.functions.path package
- easygraph.functions.structural_holes package
- Submodules
- easygraph.functions.structural_holes.AP_Greedy module
- easygraph.functions.structural_holes.HAM module
- easygraph.functions.structural_holes.HIS module
- easygraph.functions.structural_holes.ICC module
- easygraph.functions.structural_holes.MaxD module
- easygraph.functions.structural_holes.NOBE module
- easygraph.functions.structural_holes.SHII_metric module
- easygraph.functions.structural_holes.evaluation module
- easygraph.functions.structural_holes.maxBlock module
- easygraph.functions.structural_holes.metrics module
- easygraph.functions.structural_holes.weakTie module
- Module contents
- Submodules
- easygraph.functions.isolate module
- Module contents
- Subpackages
- easygraph.ml_metrics package
- easygraph.model package
- Subpackages
- easygraph.model.hypergraphs package
- Submodules
- easygraph.model.hypergraphs.dhcf module
- easygraph.model.hypergraphs.dhne module
- easygraph.model.hypergraphs.hgnn module
- easygraph.model.hypergraphs.hgnnp module
- easygraph.model.hypergraphs.hnhn module
- easygraph.model.hypergraphs.hypergcn module
- easygraph.model.hypergraphs.setgnn module
- easygraph.model.hypergraphs.unignn module
- Module contents
- easygraph.model.hypergraphs package
- Module contents
- Subpackages
- easygraph.nn package
- easygraph.readwrite package
- Subpackages
- Submodules
- easygraph.readwrite.edgelist module
- easygraph.readwrite.gexf module
- easygraph.readwrite.gml module
- easygraph.readwrite.graphml module
- easygraph.readwrite.graphviz module
- easygraph.readwrite.pajek module
- easygraph.readwrite.pickle module
- easygraph.readwrite.ucinet module
- Module contents
- easygraph.utils package
- Submodules
- easygraph.utils.alias module
- easygraph.utils.convert_class module
- easygraph.utils.convert_to_matrix module
- easygraph.utils.decorators module
- easygraph.utils.download module
- easygraph.utils.exception module
- easygraph.utils.index_of_node module
- easygraph.utils.logging module
- easygraph.utils.mapped_queue module
- easygraph.utils.misc module
- easygraph.utils.relabel module
- easygraph.utils.sparse module
- easygraph.utils.type_change module
- Module contents
Submodules
easygraph.convert module
- easygraph.convert.from_edgelist(edgelist, create_using=None)[source]
Returns a graph from a list of edges.
- Parameters:
edgelist (list or iterator) – Edge tuples
create_using (EasyGraph graph constructor, optional (default=eg.Graph)) – Graph type to create. If graph instance, then cleared before populated.
Examples
>>> edgelist = [(0, 1)] # single edge (0,1) >>> G = eg.from_edgelist(edgelist)
or
>>> G = eg.Graph(edgelist) # use Graph constructor
- easygraph.convert.from_networkx(g: nx.Graph | nx.DiGraph) Graph | DiGraph [source]
Convert a NetworkX graph to an EasyGraph graph.
- easygraph.convert.from_pyg(data: torch_geometric.data.Data, node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, to_undirected: bool | str | None = False, remove_self_loops: bool = False) Any [source]
Converts a
torch_geometric.data.Data
instance to aeasygraph.Graph
ifto_undirected
is set toTrue
, or a directedeasygraph.DiGraph
otherwise.- Parameters:
data (torch_geometric.data.Data) – The data object.
node_attrs (iterable of str, optional) – The node attributes to be copied. (default:
None
)edge_attrs (iterable of str, optional) – The edge attributes to be copied. (default:
None
)graph_attrs (iterable of str, optional) – The graph attributes to be copied. (default:
None
)to_undirected (bool or str, optional) – If set to
True
or “upper”, will return aeasygraph.Graph
instead of aeasygraph.DiGraph
. The undirected graph will correspond to the upper triangle of the corresponding adjacency matrix. Similarly, if set to “lower”, the undirected graph will correspond to the lower triangle of the adjacency matrix. (default:False
)remove_self_loops (bool, optional) – If set to
True
, will not include self loops in the resulting graph. (default:False
)
Examples
>>> import torch_geometric as pyg
>>> Data = pyg.data.Data # type: ignore >>> edge_index = torch.tensor([ ... [0, 1, 1, 2, 2, 3], ... [1, 0, 2, 1, 3, 2], ... ]) >>> data = Data(edge_index=edge_index, num_nodes=4) >>> from_pyg(data) <easygraph.classes.digraph.DiGraph at 0x2713fdb40d0>
- easygraph.convert.to_easygraph_graph(data, create_using=None, multigraph_input=False)[source]
Make a EasyGraph graph from a known data structure.
The preferred way to call this is automatically from the class constructor
>>> d = {0: {1: {"weight": 1}}} # dict-of-dicts single edge (0,1) >>> G = eg.Graph(d)
instead of the equivalent
>>> G = eg.from_dict_of_dicts(d)
- Parameters:
data (object to be converted) –
- Current known types are:
any EasyGraph graph dict-of-dicts dict-of-lists container (e.g. set, list, tuple) of edges iterator (e.g. itertools.chain) that produces edges generator of edges Pandas DataFrame (row per edge) numpy matrix numpy ndarray scipy sparse matrix pygraphviz agraph
create_using (EasyGraph graph constructor, optional (default=eg.Graph)) – Graph type to create. If graph instance, then cleared before populated.
multigraph_input (bool (default False)) – If True and data is a dict_of_dicts, try to create a multigraph assuming dict_of_dict_of_lists. If data and create_using are both multigraphs then create a multigraph from a multigraph.
- easygraph.convert.to_networkx(g: Graph | DiGraph) nx.Graph | nx.DiGraph [source]
Convert an EasyGraph to a NetworkX graph.
- easygraph.convert.to_pyg(G: Any, group_node_attrs: List[str] | all | None = None, group_edge_attrs: List[str] | all | None = None) torch_geometric.data.Data [source]
Converts a
easygraph.Graph
oreasygraph.DiGraph
to atorch_geometric.data.Data
instance.- Parameters:
G (easygraph.Graph or easygraph.DiGraph) – A easygraph graph.
group_node_attrs (List[str] or all, optional) – The node attributes to be concatenated and added to
data.x
. (default:None
)group_edge_attrs (List[str] or all, optional) – The edge attributes to be concatenated and added to
data.edge_attr
. (default:None
)
Note
All
group_node_attrs
andgroup_edge_attrs
values must be numeric.Examples
>>> import torch_geometric as pyg
>>> pyg_to_networkx = pyg.utils.convert.to_networkx # type: ignore >>> networkx_to_pyg = pyg.utils.convert.from_networkx # type: ignore >>> Data = pyg.data.Data # type: ignore >>> edge_index = torch.tensor([ ... [0, 1, 1, 2, 2, 3], ... [1, 0, 2, 1, 3, 2], ... ]) >>> data = Data(edge_index=edge_index, num_nodes=4) >>> g = pyg_to_networkx(data) >>> # A `Data` object is returned >>> to_pyg(g) Data(edge_index=[2, 6], num_nodes=4)
easygraph.exception module
Exceptions
Base exceptions and errors for EasyGraph.
- exception easygraph.exception.EasyGraphError
Bases:
EasyGraphException
Exception for a serious error in EasyGraph
- exception easygraph.exception.EasyGraphException
Bases:
Exception
Base class for exceptions in EasyGraph.
- exception easygraph.exception.EasyGraphNotImplemented
Bases:
EasyGraphException
Exception raised by algorithms not implemented for a type of graph.
- exception easygraph.exception.EasyGraphPointlessConcept
Bases:
EasyGraphException
Raised when a null graph is provided as input to an algorithm that cannot use it.
The null graph is sometimes considered a pointless concept [1], thus the name of the exception.
References