API reference

Docstrings

MetaGraphsNext.DOTFormatType
struct DOTFormat <: AbstractGraphFormat end

If all metadata types support pairs or are Nothing, you can save MetaGraphs in DOTFormat.

source
MetaGraphsNext.MetaGraphType
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 type Code
  • vertex_labels::Dict{Code,Label}: dictionary mapping vertex codes to vertex labels
  • vertex_properties::Dict{Label,Tuple{Code,VertexData}}: dictionary mapping vertex labels to vertex codes & metadata
  • edge_data::Dict{Tuple{Label,Label},EdgeData}: dictionary mapping edge labels such as (label_u, label_v) to edge metadata
  • graph_data::GraphData: metadata for the graph object as a whole
  • weight_function::WeightFunction: function computing edge weight from edge metadata, its output must have the same type as default_weight
  • default_weight::Weight: default weight used when an edge doesn't exist
source
MetaGraphsNext.MetaGraphMethod
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.

Warning

This constructor uses keyword arguments for convenience, which means it is type-unstable.

source
MetaGraphsNext.MetaGraphMethod
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_description is a vector of pairs label => data (the code of a vertex will correspond to its rank in the list)
  • edges_description is 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.

source
MetaGraphsNext.MetaGraphMethod
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.

source
Base.delete!Method
delete!(meta_graph, label_1, label_2)

Delete edge (label_1, label_2).

source
Base.getindexMethod
getindex(meta_graph, label_1, label_2)

Return edge metadata for the edge between label_1 and label_2.

source
Base.getindexMethod
getindex(meta_weights::MetaWeights, code_1, code_2)

Get the weight of edge (code_1, code_2).

source
Base.haskeyMethod
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.

source
Base.haskeyMethod
haskey(meta_graph, label)

Determine whether a MetaGraph meta_graph contains the vertex label.

source
Base.setindex!Method
setindex!(meta_graph, data, label_1, label_2)

Set edge metadata for (label_1, label_2) to data.

source
Base.setindex!Method
setindex!(meta_graph, data, label)

Set vertex metadata for label to data.

source
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.

source
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.

source
Graphs.weightsMethod
weights(meta_graph)

Return a matrix-like MetaWeights object containing the edge weights for metagraph meta_graph.

source
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.

source
MetaGraphsNext.all_neighbor_labelsMethod
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).

source
MetaGraphsNext.arrangeFunction
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 <.

source
MetaGraphsNext.code_forMethod
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.

source
MetaGraphsNext.edge_labelsMethod
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).

source
MetaGraphsNext.inneighbor_labelsMethod
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).

source
MetaGraphsNext.label_forMethod
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.

source
MetaGraphsNext.labelsMethod
labels(meta_graph)

Iterate through all vertex labels, in the same order as the codes obtained by vertices(meta_graph).

source
MetaGraphsNext.neighbor_labelsMethod
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).

source
MetaGraphsNext.outneighbor_labelsMethod
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).

source
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.

source
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.

source
Base.haskeyFunction
haskey(meta_graph, label)

Determine whether a MetaGraph meta_graph contains the vertex label.

source
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.

source
Base.getindexFunction
getindex(meta_graph)

Return meta_graph metadata.

source
getindex(meta_graph, label)

Return vertex metadata for label.

source
getindex(meta_graph, label_1, label_2)

Return edge metadata for the edge between label_1 and label_2.

source
getindex(meta_weights::MetaWeights, code_1, code_2)

Get the weight of edge (code_1, code_2).

source
Base.setindex!Function
setindex!(meta_graph, data, label)

Set vertex metadata for label to data.

source
setindex!(meta_graph, data, label_1, label_2)

Set edge metadata for (label_1, label_2) to data.

source
Base.delete!Function
delete!(meta_graph, label)

Delete vertex label.

source
delete!(meta_graph, label_1, label_2)

Delete edge (label_1, label_2).

source
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.

source
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.

source
Graphs.weightsFunction
weights(meta_graph)

Return a matrix-like MetaWeights object containing the edge weights for metagraph meta_graph.

source

Index