The following are core types in Metagraph. Below each is a description and list of concrete types. Each concrete type indicates its value_type and public-facing data objects.
value_type
1-D homogeneous array of data
Abstract Properties:
dtype: [“float”, “int”, “bool”]
GrblasVectorType
grblas.Vector
NumpyVectorType
numpy array (1-dimensional) of values
2-D homogeneous array of data
GrblasMatrixType
grblas.Matrix
NumpyMatrixType
numpy array (2-dimensional) of values
ScipyMatrixType
scipy.sparse.spmatrix
Even though this is a scipy.sparse matrix, all values are present.
scipy.sparse
2-D table of data where each column has a unique name and may have a unique dtype.
<none>
PandasDataFrameType
pandas.DataFrame
A set of NodeIDs.
Standard Wrapper Methods:
num_nodes() -> int
__contains__(NodeID) -> bool
GrblasNodeSet.Type
GrblasNodeSet
.value: grblas.Vector with missing values indicating the NodeID is not part of the set
.value
The dtype of the Vector is not restricted. The only indication of existence in the set is that the value is not missing. There is no guarantee of what the value actually is.
dtype
NumpyNodeSet.Type
NumpyNodeSet
.value: numpy array of all NodeIDs in sorted order
PythonNodeSet.Type
PythonNodeSet
.value: Python set of NodeIds
A set of NodeIDs and associated values, one for each node.
Can be translated to:
NodeSet
__getitem__(NodeID) -> Any
GrblasNodeMap.Type
GrblasNodeMap
.value: grblas.Vector containing values for NodeIDs; missing values are not in the set of nodes
NumpyNodeMap.Type
NumpyNodeMap
.value: numpy array of values
.nodes: numpy array of all NodeIDs in sorted order
.nodes
PythonNodeMap.Type
PythonNodeMap
.value: a Python dict mapping NodeID to value
A set of edges connecting nodes.
is_directed: [True, False]
GrblasEdgeSet.Type
GrblasEdgeSet
.value: grblas.Matrix representing an adjacency matrix
.transposed: bool
.transposed
The indices of the matrix indicate the NodeIDs of the edges.
Missing values in the matrix indicate the edge is not in the set. If there is a value, the edge is part of the set, but the dtype is not restricted (i.e. don’t assume boolean or 1/0).
PandasEdgeSet.Type
PandasEdgeSet
.value: pandas.DataFrame with 2 columns
.src_label: str name of column containing source NodeIDs
.src_label
.dst_label: str name of column containing destination NodeIDs
.dst_label
.is_directed: bool indicating whether to assume directed edges
.is_directed
.index: pre-built pandas MultiIndex of (src_label, dst_label) tuples
.index
If is_directed is False, edges are not duplicated in both directions to save space.
is_directed
ScipyEdgeSet.Type
ScipyEdgeSet
.value: scipy.sparse matrix representing an adjacency matrix
.node_list: numpy array of NodeIDs corresponding to indices in the matrix
.node_list
The indices of the matrix do not represent NodeIDs. Instead, they represent positions within node_list which holds the actual NodeIDs. If only n nodes exist in the edge set, the matrix will be n x n.
node_list
n
n x n
There is no guarantee for the matrix dtype. Presence or absence of a value is the only indication that the edge exists in the edge set.
A set of edges connecting nodes. Each edge is associated with a value (i.e. weight).
has_negative_weights: [True, False]
EdgeSet
GrblasEdgeMap.Type
GrblasEdgeMap
.value: grblas.Matrix
Values in the matrix are the weighted edges.
PandasEdgeMap.Type
PandasEdgeMap
.value: pandas.DataFrame with 3 columns
.weight_label: str name of column containing the weights
.weight_label
ScipyEdgeMap.Type
ScipyEdgeMap
The values in the matrix are the edge weights.
The format of the scipy sparse matrix (csr, csc, coo, dok, lil) is not constrained. Use the .format() method to check.
.format()
Note about zeros: scipy sparse assumes missing values are equivalent to zeros. Few if any other graph libraries make this assumption because it makes it impossible to differentiate between edges with a weight of 0 and the lack of an edge. Care must be taken when using the scipy sparse matrix to avoid surprises resulting from this conflation of ideas.
A combination of edges and nodes, each of which may hold values or not. Additionally, a Graph may have isolate nodes (containing no edges), which an EdgeSet/Map cannot have.
node_type: [“set”, “map”]
node_dtype: [“float”, “int”, “bool”, None]
edge_type: [“set”, “map”]
edge_dtype: [“float”, “int”, “bool”, None]
edge_has_negative_weights: [True, False, None]
GrblasGraph.Type
GrblasGraph
.value: adjacency grblas.Matrix
.nodes: optional grblas.Vector
The position index in the sparse matrix indicates the NodeId.
If nodes is None, the nodes are assumed to be sequential for [0..nrows] of the matrix. nodes indicate which nodes are present in the graph and may also indicate the value associated with each node.
nodes
NetworkXGraph.Type
NetworkXGraph
.value: nx.Graph or nx.DiGraph
.node_weight_label: key within the node attrs containing the weight
.node_weight_label
.edge_weight_label: key within the edge attrs containing the weight
.edge_weight_label
NodeIDs are required to be integers, which is a restriction imposed by Metagraph to allow for consistent representation by other Graph types. If non-integer labels are desired, use Node Labels.
If any node has a weight, all nodes must have a weight.
If any edge has a weight, all edges must have a weight.
ScipyGraph.Type
ScipyGraph
.value: adjacency scipy.sparse.spmatrix
.node_list: optional np.ndarray
np.ndarray
.node_vals: optional np.ndarray
.node_vals
The sparse matrix must be a square matrix sized to hold all nodes in the graph (including isolate nodes).
If nodes is None, the nodes are assumed to be sequential for [0..nrows] of the matrix. If the nodes are not sequential, the node_list provides a mapping from matrix index to NodeId.
If values are associated with each node, they will be contained in node_vals. Otherwise it will be None.
node_vals
Representation of a bipartite graph with two unique node groups (0 and 1) and edges which exist only between nodes from different node groups. Like Graphs, nodes and edges may have values.
node0_type: [“set”, “map”]
node1_type: [“set”, “map”]
node0_dtype: [“float”, “int”, “bool”, None]
node1_dtype: [“float”, “int”, “bool”, None]
NetworkXBipartiteGraph.Type
NetworkXBipartiteGraph
.nodes: 2-tuple of sets of NodeIDs
The two node groups within the bipartite graph are represented by their position within nodes.
If any node has a weight, all nodes must have a weight. This includes nodes from both node sets 0 and 1.
Holds an embedding for each node, extracted from a graph. Conceptually, this can be thought of as a dense matrix with each row applying to a single NodeID.
matrix_dtype: [“float”, “int”, “bool”]
NumpyNodeEmbedding.Type
NumpyNodeEmbedding
.matrix: NumpyMatrix
.matrix
NumpyMatrix
.nodes: optional NumpyNodeMap
If nodes is None, the nodes are assumed to be fully sequential, corresponding to the height of the matrix.