API reference
Docstrings
MetaGraphsNext.MetaGraphsNext — Module
MetaGraphsNextA package for graphs with vertex labels and metadata in Julia. Its main export is the MetaGraph type.
MetaGraphsNext.DOTFormat — Type
struct DOTFormat <: AbstractGraphFormat endIf all metadata types support pairs or are Nothing, you can save MetaGraphs in DOTFormat.
MetaGraphsNext.MGFormat — Type
struct MGFormat <: AbstractGraphFormat endYou can save MetaGraphs in a MGFormat, currently based on JLD2.
MetaGraphsNext.MetaGraph — Type
MetaGraph{
Code<:Integer,
Graph<:AbstractGraph{Code},
Label,
VertexData,
EdgeData,
GraphData,
WeightFunction,
Weight
} <: AbstractGraph{Code}A graph type with custom vertex labels containing vertex-, edge- and graph-level metadata.
Vertex labels have type Label, while vertex (resp. edge, resp. graph) metadata has type VertexData (resp. EdgeData, resp. GraphData). It is recommended not to set Label to an integer type, so as to avoid confusion between vertex labels (which do not change as the graph evolves) and vertex codes (which have type Code<:Integer and can change as the graph evolves).
Fields
graph::Graph: underlying, data-less graph with vertex codes of typeCodevertex_labels::Dict{Code,Label}: dictionary mapping vertex codes to vertex labelsvertex_properties::Dict{Label,Tuple{Code,VertexData}}: dictionary mapping vertex labels to vertex codes & metadataedge_data::Dict{Tuple{Label,Label},EdgeData}: dictionary mapping edge labels such as(label_u, label_v)to edge metadatagraph_data::GraphData: metadata for the graph object as a wholeweight_function::WeightFunction: function computing edge weight from edge metadata, its output must have the same type asdefault_weightdefault_weight::Weight: default weight used when an edge doesn't exist
MetaGraphsNext.MetaGraph — Method
MetaGraph(
graph;
label_type,
vertex_data_type=Nothing,
edge_data_type=Nothing,
graph_data=nothing,
weight_function=edge_data -> 1.0,
default_weight=1.0
)Construct an empty MetaGraph based on an empty graph, initializing storage with metadata types given as keyword arguments.
MetaGraphsNext.MetaGraph — Method
MetaGraph(
graph,
vertices_description,
edges_description,
graph_data=nothing,
weight_function=edge_data -> 1.0,
default_weight=1.0,
)Construct a non-empty MetaGraph based on a non-empty graph with specified vertex and edge data, given as positional arguments.
The data must be given as follows:
vertices_descriptionis a vector of pairslabel => data(the code of a vertex will correspond to its rank in the list)edges_descriptionis a vector of pairs(label1, label2) => data
Furthermore, these arguments must be coherent with the graph argument, i.e. describe the same set of vertices and edges.
MetaGraphsNext.MetaGraph — Method
MetaGraph(
graph,
label_type,
vertex_data_type=Nothing,
edge_data_type=Nothing,
graph_data=nothing,
weight_function=edge_data -> 1.0,
default_weight=1.0
)Construct an empty MetaGraph based on an empty graph, initializing storage with metadata types given as positional arguments.
Base.delete! — Method
delete!(meta_graph, label_1, label_2)Delete edge (label_1, label_2).
Base.delete! — Method
delete!(meta_graph, label)Delete vertex label.
Base.getindex — Method
getindex(meta_graph, label_1, label_2)Return edge metadata for the edge between label_1 and label_2.
Base.getindex — Method
getindex(meta_graph, label)Return vertex metadata for label.
Base.getindex — Method
getindex(meta_weights::MetaWeights, code_1, code_2)Get the weight of edge (code_1, code_2).
Base.getindex — Method
getindex(meta_graph)Return meta_graph metadata.
Base.haskey — Method
haskey(meta_graph, label_1, label_2)Determine whether a MetaGraph meta_graph contains an edge from label_1 to label_2.
The order of label_1 and label_2 only matters if meta_graph is a digraph.
Base.haskey — Method
haskey(meta_graph, label)Determine whether a MetaGraph meta_graph contains the vertex label.
Base.setindex! — Method
setindex!(meta_graph, data, label_1, label_2)Set edge metadata for (label_1, label_2) to data.
Base.setindex! — Method
setindex!(meta_graph, data, label)Set vertex metadata for label to data.
Graphs.SimpleGraphs.add_edge! — Method
add_edge!(meta_graph, label_1, label_2, data)Add an edge (label_1, label_2) to MetaGraph meta_graph with metadata data. If the EdgeData type of meta_graph is Nothing, data can be omitted.
Return true if the edge has been added, false otherwise. If one of the labels does not exist, nothing happens and false is returned (the label is not inserted). If (label_1, label_2) already exists, its data is updated to data and false is returned nonetheless.
Graphs.SimpleGraphs.add_vertex! — Method
add_vertex!(meta_graph, label, data)Add a vertex to MetaGraph meta_graph with label label having metadata data. If the VertexData type of meta_graph is Nothing, data can be omitted.
Return true if the vertex has been added, false in case the label already exists or vertex was not added.
Graphs.weights — Method
weights(meta_graph)Return a matrix-like MetaWeights object containing the edge weights for metagraph meta_graph.
MetaGraphsNext._copy_props! — Method
_copy_props!(old_meta_graph, new_meta_graph, code_map)Copy properties from old_meta_graph to new_meta_graph following vertex map code_map.
MetaGraphsNext.all_neighbor_labels — Method
all_neighbor_labels(meta_graph, label)Iterate through all labels of all neighbors of the vertex code with label label, in the same order as the codes obtained by all_neighbors(meta_graph, code).
MetaGraphsNext.arrange — Function
arrange(graph, label_1, label_2)Sort two vertex labels in a default order (useful to uniquely express undirected edges). For undirected graphs, the default order is based on the labels themselves to be robust to vertex re-coding, so the labels need to support <.
MetaGraphsNext.code_for — Method
code_for(meta_graph::MetaGraph, label)Find the vertex code (or index) associated with label label.
This can be useful to pass to methods inherited from Graphs. Note, however, that vertex codes can be reassigned after vertex deletion.
MetaGraphsNext.default_weight — Method
default_weight(meta_graph)Return the default weight for metagraph meta_graph.
MetaGraphsNext.edge_labels — Method
edge_labels(meta_graph)Iterate through all tuples of edge labels, in the same order as the tuples of codes obtained by edges(meta_graph).
MetaGraphsNext.get_weight_function — Method
get_weight_function(meta_graph)Return the weight function for metagraph meta_graph.
MetaGraphsNext.inneighbor_labels — Method
inneighbor_labels(meta_graph, label)Iterate through all labels of inneighbors of the vertex code with label label, in the same order as the codes obtained by inneighbors(meta_graph, code).
MetaGraphsNext.label_for — Method
label_for(meta_graph::MetaGraph, code)Find the label associated with code code.
This can be useful to interpret the results of methods inherited from Graphs. Note, however, that vertex codes can be reassigned after vertex deletion.
MetaGraphsNext.labels — Method
labels(meta_graph)Iterate through all vertex labels, in the same order as the codes obtained by vertices(meta_graph).
MetaGraphsNext.neighbor_labels — Method
neighbor_labels(meta_graph, label)Iterate through all labels of neighbors of the vertex code with label label, in the same order as the codes obtained by neighbors(meta_graph, code).
MetaGraphsNext.outneighbor_labels — Method
outneighbor_labels(meta_graph, label)Iterate through all labels of outneighbors of the vertex code with label label, in the same order as the codes obtained by outneighbors(meta_graph, code).
MetaGraphsNext.set_data! — Method
set_data!(meta_graph, label_1, label_2, data)Set edge metadata for (label_1, label_2) to data.
Return true if the operation succeeds, and false if meta_graph has no such edge.
MetaGraphsNext.set_data! — Method
set_data!(meta_graph, label, data)Set vertex metadata for label to data.
Return true if the operation succeeds, and false if meta_graph has no such vertex.
MetaGraphsNext.weighttype — Method
weighttype(meta_graph)Return the weight type for metagraph meta_graph.
Base.haskey — Function
haskey(meta_graph, label)Determine whether a MetaGraph meta_graph contains the vertex label.
haskey(meta_graph, label_1, label_2)Determine whether a MetaGraph meta_graph contains an edge from label_1 to label_2.
The order of label_1 and label_2 only matters if meta_graph is a digraph.
Base.getindex — Function
getindex(meta_graph)Return meta_graph metadata.
getindex(meta_graph, label)Return vertex metadata for label.
getindex(meta_graph, label_1, label_2)Return edge metadata for the edge between label_1 and label_2.
getindex(meta_weights::MetaWeights, code_1, code_2)Get the weight of edge (code_1, code_2).
Base.setindex! — Function
setindex!(meta_graph, data, label)Set vertex metadata for label to data.
setindex!(meta_graph, data, label_1, label_2)Set edge metadata for (label_1, label_2) to data.
Base.delete! — Function
delete!(meta_graph, label)Delete vertex label.
delete!(meta_graph, label_1, label_2)Delete edge (label_1, label_2).
Graphs.SimpleGraphs.add_vertex! — Function
add_vertex!(meta_graph, label, data)Add a vertex to MetaGraph meta_graph with label label having metadata data. If the VertexData type of meta_graph is Nothing, data can be omitted.
Return true if the vertex has been added, false in case the label already exists or vertex was not added.
Graphs.SimpleGraphs.add_edge! — Function
add_edge!(meta_graph, label_1, label_2, data)Add an edge (label_1, label_2) to MetaGraph meta_graph with metadata data. If the EdgeData type of meta_graph is Nothing, data can be omitted.
Return true if the edge has been added, false otherwise. If one of the labels does not exist, nothing happens and false is returned (the label is not inserted). If (label_1, label_2) already exists, its data is updated to data and false is returned nonetheless.
Graphs.weights — Function
weights(meta_graph)Return a matrix-like MetaWeights object containing the edge weights for metagraph meta_graph.
Index
MetaGraphsNext.MetaGraphsNextMetaGraphsNext.DOTFormatMetaGraphsNext.MGFormatMetaGraphsNext.MetaGraphMetaGraphsNext.MetaGraphMetaGraphsNext.MetaGraphMetaGraphsNext.MetaGraphBase.delete!Base.delete!Base.delete!Base.getindexBase.getindexBase.getindexBase.getindexBase.getindexBase.haskeyBase.haskeyBase.haskeyBase.setindex!Base.setindex!Base.setindex!Graphs.SimpleGraphs.add_edge!Graphs.SimpleGraphs.add_edge!Graphs.SimpleGraphs.add_vertex!Graphs.SimpleGraphs.add_vertex!Graphs.weightsGraphs.weightsMetaGraphsNext._copy_props!MetaGraphsNext.all_neighbor_labelsMetaGraphsNext.arrangeMetaGraphsNext.code_forMetaGraphsNext.default_weightMetaGraphsNext.edge_labelsMetaGraphsNext.get_weight_functionMetaGraphsNext.inneighbor_labelsMetaGraphsNext.label_forMetaGraphsNext.labelsMetaGraphsNext.neighbor_labelsMetaGraphsNext.outneighbor_labelsMetaGraphsNext.set_data!MetaGraphsNext.set_data!MetaGraphsNext.weighttype