GraphOptInterface

Documentation for GraphOptInterface.

GraphOptInterface.EdgeType
Edge

An edge represents different types of coupling. For instance an Edge{Tuple{Node}} is an edge the couple variables within a single node. An Edge{Tuple{N,Node}} couple variables across one or more nodes.

source
GraphOptInterface.EdgeMethod
Edge(graph_index::GraphIndex, edge_index::EdgeIndex, nodes::NTuple{N,Node})

Construct a new Edge connecting the given tuple of nodes. Initializes an empty MOI model and edge index map for storing coupling constraints.

source
GraphOptInterface.EdgeIndexMapType
EdgeIndexMap

A bidirectional mapping between edge variables and their corresponding node variables. Contains mappings from edge variables to (Node, MOI.VariableIndex) tuples and vice versa.

source
GraphOptInterface.HyperEdgeType
HyperEdge

A hyperedge connecting multiple hypernodes in a hypergraph. Contains a set of vertices (hypernodes) that the edge connects.

source
GraphOptInterface.HyperMapType
HyperMap

A mapping from an OptiGraph to a graph view that supports various graph query functions. Currently supports a HyperGraph as the graph view.

source
GraphOptInterface.HyperMapMethod
HyperMap(graph::OptiGraph, hypergraph::HyperGraph)

Construct a new HyperMap with empty mappings between the given graph and hypergraph.

source
GraphOptInterface.NodeMethod
Node(graph_index::GraphIndex, node_index::NodeIndex)

Construct a new Node with the given graph and node indices. Initializes an empty MOI model for storing variables and constraints.

source
GraphOptInterface.OptiGraphType
OptiGraph

A hierarchical graph structure for representing optimization problems with block structure. Contains nodes (representing subproblems), edges (representing coupling constraints), and subgraphs (for hierarchical decomposition).

Fields

  • index::GraphIndex: Unique identifier for the graph
  • parent::Union{Nothing,OptiGraph}: Parent graph (if this is a subgraph)
  • nodes::Vector{Node}: Nodes in this graph
  • edges::Vector{Edge}: Edges in this graph
  • subgraphs::Vector{OptiGraph}: Child subgraphs
  • node_by_index::OrderedDict{NodeIndex,Node}: Lookup map for nodes
  • edge_by_index::OrderedDict{EdgeIndex,Edge}: Lookup map for edges
  • subgraph_by_index::OrderedDict{GraphIndex,OptiGraph}: Lookup map for subgraphs
source
Base.:==Method
Base.:(==)(h1::HyperEdge, h2::HyperEdge)

Check if two hyperedges are equal by comparing their vertex sets.

source
Base.getindexMethod
Base.getindex(hypergraph::HyperGraph, edge::HyperEdge)

Get the integer index of a hyperedge in the hypergraph.

source
Base.getindexMethod
Base.getindex(hypergraph::HyperGraph, node::HyperNode)

Get the index of a hypernode (returns the node itself as the index).

source
Base.getindexMethod
Base.getindex(hyper_map::HyperMap, edge::Edge)

Get the HyperEdge that corresponds to the given edge in the hyper map.

source
Base.getindexMethod
Base.getindex(hyper_map::HyperMap, hyperedge::HyperEdge)

Get the Edge that corresponds to the given hyperedge in the hyper map.

source
Base.getindexMethod
Base.getindex(hyper_map::HyperMap, node::Node)

Get the HyperNode that corresponds to the given node in the hyper map.

source
Base.getindexMethod
Base.getindex(hyper_map::HyperMap, vertex::HyperNode)

Get the Node that corresponds to the given vertex in the hyper map.

source
Base.reverseMethod
Base.reverse(e::HyperEdge)

Hyperedges do not support reversal. Throws an error.

source
Base.setindex!Method
Base.setindex!(hyper_map::HyperMap, edge::Edge, hyperedge::HyperEdge)

Set the mapping from edge to hyperedge in the hyper map.

source
Base.setindex!Method
Base.setindex!(hyper_map::HyperMap, hyperedge::HyperEdge, edge::Edge)

Set the mapping from hyperedge to edge in the hyper map.

source
Base.setindex!Method
Base.setindex!(hyper_map::HyperMap, node::Node, vertex::HyperNode)

Set the mapping from node to vertex in the hyper map.

source
Base.setindex!Method
Base.setindex!(hyper_map::HyperMap, vertex::HyperNode, node::Node)

Set the mapping from vertex to node in the hyper map.

source
GraphOptInterface.all_incident_edgesMethod
all_incident_edges(hyper_map::HyperMap, nodes::Vector{Node})::Vector{Edge}

Return all of the edges within the optigraph in hyper_map that are incident to the vector of supplied nodes.

source
GraphOptInterface.all_neighborsMethod
all_neighbors(hyper_map::HyperMap, nodes::Vector{Node})::Vector{Node}

Return the neighbor nodes within the optigraph in hyper_map to the vector of supplied optigraph nodes.

source
GraphOptInterface.build_hypergraph_mapMethod
build_hypergraph_map(graph::OptiGraph)

Build a HyperMap that maps the given graph to a HyperGraph representation. Creates hypernodes for each node and hyperedges for each edge in the graph. Returns the complete mapping.

source
GraphOptInterface.children_incident_edgesMethod
children_incident_edges(hyper_map::HyperMap, graph::OptiGraph)::Vector{Edge}

Return all of the optigraph edges that are incident to the supplied graph that are strictly child connections.

source
GraphOptInterface.expandMethod
expand(g::HyperGraph, nodes::Vector{HyperNode}, distance::Int64)

Expand the given nodes by the specified distance. Returns a tuple of (new_nodes, new_edges) where new_nodes includes all nodes within distance and new_edges are the induced hyperedges on those nodes.

source
GraphOptInterface.get_nodes_to_depthFunction
get_nodes_to_depth(graph::OptiGraph, depth::Int=0)

Return nodes in graph up to the specified depth of subgraphs. A depth of 0 returns only nodes in the current graph, depth of 1 includes immediate subgraph nodes, etc.

source
GraphOptInterface.identify_edgesMethod
identify_edges(hypergraph::HyperGraph,partitions::Vector{Vector{HyperNode}})

Identify both induced partition edges and cut edges given a partition of HyperNode vectors.

source
GraphOptInterface.identify_nodesMethod
identify_nodes(hypergraph::HyperGraph,partitions::Vector{Vector{HyperEdge}})

Identify both induced partition nodes and cut nodes given a partition of HyperEdge vectors.

source
GraphOptInterface.identify_separatorsMethod
identify_separators(bgraph::BipartiteGraph, partitions::Vector; cut_selector=Graphs.degree)

Identify separator elements (cut vertices or cut edges) that separate the given partitions. The cut_selector parameter determines how to assign boundary elements to cuts. It can be:

  • A function (e.g., Graphs.degree) that compares element degrees
  • :vertex to always assign vertices as separators
  • :edge to always assign edges as separators

Returns a tuple (partition_elements, cross_elements) where partition_elements are the elements local to each partition and cross_elements are the separator elements.

source
GraphOptInterface.induced_edgesMethod
induced_edges(hypergraph::HyperGraph,hypernodes::Vector{HyperNode})

Identify the induced hyperedges to a vector of HyperNodes.

NOTE: This currently does not support hypergraphs with unconnected nodes

source
GraphOptInterface.induced_elementsMethod
induced_elements(bgraph::BipartiteGraph, partitions::Vector; cut_selector=Graphs.degree)

Get the induced elements for each partition (i.e., elements local to each partition, excluding separators). This is a convenience function that returns only the first element of identify_separators.

Arguments

  • bgraph::BipartiteGraph: The bipartite graph
  • partitions::Vector: Vector of partitions
  • cut_selector=Graphs.degree: Selector for determining cut assignment (function, :vertex, or :edge)

Returns

A vector of vectors, where each inner vector contains the induced elements for that partition.

source
GraphOptInterface.neighborhoodMethod
neighborhood(g::HyperGraph, nodes::Vector{HyperNode}, distance::Int64)

Retrieve the neighborhood within distance of nodes. Returns a vector containing the original vertices and all vertices within the specified distance.

source
GraphOptInterface.node_variablesMethod
node_variables(edge::Edge)::Vector{Tuple{Node,MOI.VariableIndex}}

Return a vector of tuples where each tuple contains the node and variable index associated with each edge variable.

source
GraphOptInterface.non_parent_incident_edgesMethod
non_parent_incident_edges(hyper_map::HyperMap, subgraph::OptiGraph)::Vector{Edge}

Return all of the optigraph edges that are incident to the supplied subgraph that are strictly not parent connections.

source
GraphOptInterface.non_parent_neighborsMethod
non_parent_neighbors(hyper_map::HyperMap, subgraph::OptiGraph)::Vector{Node}

Return the neighbor nodes in subgraph based on the optigraph in hyper_map that are not in the parent graph of `subgraph.

source
GraphOptInterface.parent_incident_edgesMethod
parent_incident_edges(hyper_map::HyperMap, subgraph::OptiGraph)::Vector{Edge}

Return all of the optigraph edges that are incident to the supplied subgraph that are strictly parent connections.

source
GraphOptInterface.parent_neighborsMethod
parent_neighbors(hyper_map::HyperMap, subgraph::OptiGraph)::Vector{Node}

Return the neighbor nodes in subgraph based on the optigraph in hyper_map that are only in the parent graph of `subgraph.

source
GraphOptInterface.supports_graph_interfaceMethod
supports_graph_interface(optimizer::MOI.AbstractOptimizer)

Check if the given optimizer supports the graph interface. Returns false for standard MOI optimizers and true for AbstractGraphOptimizer subtypes.

source
Graphs.LinAlg.adjacency_matrixMethod
Graphs.adjacency_matrix(bgraph::BipartiteGraph)

Return the adjacency matrix of the bipartite graph. Rows correspond to vertices in the first set, columns correspond to vertices in the second set.

source
Graphs.LinAlg.incidence_matrixMethod
Graphs.incidence_matrix(hypergraph::HyperGraph)

Obtain the incidence matrix representation of hypergraph. Rows correspond to vertices. Columns correspond to hyperedges. Returns a sparse matrix.

source
Graphs.SimpleGraphs.add_edge!Method
Graphs.add_edge!(bgraph::BipartiteGraph, from::Int64, to::Int64)

Add an edge between vertices from and to. Enforces bipartite structure by requiring that the vertices be in different vertex sets.

source
Graphs.SimpleGraphs.add_edge!Method
Graphs.add_edge!(hypergraph::HyperGraph, hypernodes::HyperNode...)

Add a hyperedge connecting the given hypernodes. If the hyperedge already exists, returns the existing hyperedge. Requires at least 2 hypernodes.

source
Graphs.SimpleGraphs.add_vertex!Method
Graphs.add_vertex!(bgraph::BipartiteGraph; bipartite=1)

Add a vertex to the bipartite graph. The bipartite keyword argument specifies which vertex set to add the vertex to (1 or 2). Returns the success status.

source
Graphs.all_neighborsMethod
Graphs.all_neighbors(g::HyperGraph, node::HyperNode)

Return all neighbor nodes of the given node in sorted order. Neighbors are nodes that share at least one hyperedge with the given node.

source
Graphs.degreeMethod
Graphs.degree(g::HyperGraph, v::Int)

Return the degree of vertex v (the number of unique neighbors).

source
Graphs.edgesMethod
Graphs.edges(bgraph::BipartiteGraph)

Return an iterator over all edges in the bipartite graph.

source
Graphs.edgesMethod
Graphs.edges(hypergraph::HyperGraph)

Return an iterator over all hyperedges in the hypergraph.

source
Graphs.edgetypeMethod
Graphs.edgetype(bgraph::BipartiteGraph)

Return the edge type for a bipartite graph (SimpleEdge{Int64}).

source
Graphs.edgetypeMethod
Graphs.edgetype(graph::HyperGraph)

Return the edge type for a hypergraph (HyperEdge).

source
Graphs.has_edgeMethod
Graphs.has_edge(bgraph::BipartiteGraph, from::Int64, to::Int64)

Check if the bipartite graph has an edge from from to to.

source
Graphs.has_edgeMethod
Graphs.has_edge(graph::HyperGraph, edge::HyperEdge)

Check if the hypergraph contains the given hyperedge.

source
Graphs.has_edgeMethod
Graphs.has_edge(graph::HyperGraph, hypernodes::Set{HyperNode})

Check if the hypergraph has a hyperedge connecting the given set of hypernodes.

source
Graphs.has_vertexMethod
Graphs.has_vertex(bgraph::BipartiteGraph, v::Integer)

Check if the bipartite graph contains vertex v.

source
Graphs.has_vertexMethod
Graphs.has_vertex(graph::HyperGraph, v::Integer)

Check if the hypergraph contains the given vertex.

source
Graphs.is_directedMethod
Graphs.is_directed(bgraph::BipartiteGraph)

Bipartite graphs are undirected. Always returns false.

source
Graphs.is_directedMethod
Graphs.is_directed(graph::HyperGraph)

Hypergraphs are undirected. Always returns false.

source
Graphs.is_directedMethod
Graphs.is_directed(::Type{BipartiteGraph})

Bipartite graphs are undirected. Always returns false.

source
Graphs.is_directedMethod
Graphs.is_directed(::Type{HyperGraph})

Hypergraphs are undirected. Always returns false.

source
Graphs.neMethod
Graphs.ne(bgraph::BipartiteGraph)

Return the number of edges in the bipartite graph.

source
Graphs.neMethod
Graphs.ne(graph::HyperGraph)

Return the number of hyperedges in the hypergraph.

source
Graphs.nvMethod
Graphs.nv(bgraph::BipartiteGraph)

Return the number of vertices in the bipartite graph.

source
Graphs.nvMethod
Graphs.nv(graph::HyperGraph)

Return the number of vertices (hypernodes) in the hypergraph.

source
Graphs.verticesMethod
Graphs.vertices(bgraph::BipartiteGraph)

Return a vector of all vertices in the bipartite graph.

source
Graphs.verticesMethod
Graphs.vertices(hyperedge::HyperEdge)

Return a vector of all vertices connected by the hyperedge.

source
Graphs.verticesMethod
Graphs.vertices(graph::HyperGraph)

Return a vector of all vertices in the hypergraph.

source
MathOptInterface.add_variableMethod
MOI.add_variable(edge::Edge, node::Node, variable::MOI.VariableIndex)

Add a variable to the edge that maps to the given variable on the specified node. Returns the edge's variable index for use in edge constraints.

source