Graph algorithms
Bipartite Graph
Maximum clique
MolecularGraph.all_maximal_cliques
— Methodall_maximal_cliques(::Type{U}, g::SimpleGraph{T}; kwargs...
) where {T,U} -> (Vector{U}, Symbol)
Calculate maximal cliques.
Reference
- Tomita, E., Tanaka, A., & Takahashi, H. (2006). The worst-case time complexity for generating all maximal cliques and computational experiments. Theoretical Computer Science, 363(1), 28–42. https://doi.org/10.1016/J.TCS.2006.06.015
- Cazals, F., & Karande, C. (2008). A note on the problem of reporting maximal cliques. Theoretical Computer Science, 407(1–3), 564–568. https://doi.org/10.1016/j.tcs.2008.05.010
MolecularGraph.all_maximal_conn_cliques
— Methodall_maximal_conn_cliques(::Type{U}, g::SimpleGraph{T}, eattrs::Dict;
kwargs...) where {T,U} -> (Vector{U}, Symbol)
Calculate maximal connected cliques.
Reference
- Cazals, F., & Karande, C. (2005). An algorithm for reporting maximal c-cliques. Theoretical Computer Science, 349(3), 484–490. https://doi.org/10.1016/j.tcs.2005.09.038
MolecularGraph.approx_maximum_clique
— Methodapprox_maximum_clique(g) -> Vector{Int}
Return approximate maximal cliques.
Reference:
- Boppana, R., & Halldórsson, M. M. (1992).
- https://networkx.org/documentation/stable/modules/networkx/algorithms/approximation/clique.html#maxclique
MolecularGraph.maximum_clique
— Methodmaximum_clique(::Type{U}, g::SimpleGraph{T}; kwargs...) where {T,U} -> (U, Symbol)
Calculate maximum clique.
MolecularGraph.maximum_conn_clique
— Methodmaximum_conn_clique(::Type{U}, g::SimpleGraph{T}, eattrs::Dict;
kwargs...) where {T,U} -> (U, Symbol)
Calculate maximal connected cliques.
Cycle basis
MolecularGraph.mincyclebasis
— Methodmincyclebasis(graph::UndirectedGraph) -> Vector{Vector{Int}}
Returns minimum cycle basis represented as an array of edge sequence that make up a cycle.
Reference
- de Pina, J.C. Applications of shortest path methods. PhD thesis, University of Amsterdam, Nether-lands (1995)
- Kavitha, T., Mehlhorn, K., Michail, D. & Paluch, K. E. An $\tilde{O}(m^{2}n)$ Algorithm for Minimum Cycle Basis of Graphs. Algorithmica 52, 333–349 (2008).
Maximum common subgraph (Clique detection based algorithm)
MolecularGraph.maximum_common_subgraph
— Methodmaximum_common_subgraph(g::ConstraintArrayMCIS, h::ConstraintArrayMCIS;
connected=false, kwargs...) -> (Dict, Symbol)
Compute maximum common node-induced subgraph (MCIS) between the two MCS constraints.
MolecularGraph.maximum_common_subgraph
— Methodmaximum_common_subgraph(g::ConstraintArrayMCES, h::ConstraintArrayMCES;
connected=false, kwargs...) -> (Dict, Symbol)
Compute maximum common edge-induced subgraph (MCES) between the two MCS constraints.
MolecularGraph.modular_product
— Methodmodular_product(g::ConstraintArrayMCS, h::ConstraintArrayMCS;
tolerance=0, kwargs...) -> SimpleGraph
Compute modular product of the two MCS constrait arrays.
Subgraph isomorphism match (VF2 algorithm)
MolecularGraph.edgesubgraph_is_isomorphic
— Methodedgesubgraph_is_isomorphic(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Bool
Return whether an edge-induced subgraph of G
is isomorphic to H
.
MolecularGraph.edgesubgraph_isomorphisms
— Methodedgesubgraph_isomorphisms(
g::SimpleGraph, h::SimpleGraph;
vmatch=(g,h)->true, ematch=(g,h)->true,
kwargs...) -> Iterator
Return an iterator that generate isomorphic mappings between H
and edge-induced subgraphs of G
. The returned iterator has ig => ih
pairs that correspond to the indices of matching edges in G
and H
, respectively.
vmatch
and ematch
control the features needed to be counted as a match.
See Graphs.induced_subgraph
to construct the subgraphs that result from the match.
MolecularGraph.is_isomorphic
— Methodis_isomorphic(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Bool
Return whether G
and H
are isomorphic.
MolecularGraph.isomorphisms
— Methodisomorphisms(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Iterator
Return an iterator that generate isomorphic mappings between G
and H
. The returned iterator has ig => ih
pairs that correspond to the indices of matching nodes in G
and H
, respectively.
MolecularGraph.nodesubgraph_is_isomorphic
— Methodnodesubgraph_is_isomorphic(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Bool
Return whether a node-induced subgraph of G
is isomorphic to H
.
MolecularGraph.nodesubgraph_isomorphisms
— Methodnodesubgraph_isomorphisms(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Iterator
Return an iterator that generate isomorphic mappings between H
and node-induced subgraphs of G
. The returned iterator has ig => ih
pairs that correspond to the indices of matching nodes in G
and H
, respectively.
MolecularGraph.subgraph_is_monomorphic
— Methodsubgraph_is_monomorphic(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Bool
Return whether a subgraph of G
is monomorphic to H
.
MolecularGraph.subgraph_monomorphisms
— Methodsubgraph_monomorphisms(g::SimpleGraph, h::SimpleGraph; kwargs...) -> Iterator
Generate monomorphism mappings between H
and subgraphs of G
. The returned iterator has ig => ih
pairs that correspond to the indices of matching nodes in G
and H
, respectively.
MolecularGraph.VF2Matcher
— TypeVF2Matcher{T,U,G<:SimpleGraph{T},H<:SimpleGraph{U}}
Lazy iterator that generate all isomorphism mappings between G
and H
.
matchtype
should be one of the followings
:isomorphic
: G is isomorphic to H:subgraph_isomorphic
: a node-induced subgraph of G is isomorphic to H:monomorphic
: a subgraph of G is monomorphic to H
Options
vmatch::Function
: a function for semantic node attribute matching (default: (a, b) -> true)ematch::Function
: a function for semantic edge attribute matching (default: (a, b) -> true)mandatory::Dict{Int,Int}
: mandatory node mapping (if matchtype=:edgeinduced, edge mapping)forbidden::Dict{Int,Int}
: forbidden node mapping (if matchtype=:edgeinduced, edge mapping)timeout::Union{Int,Nothing}
: if specified, abort vf2 calculation when the time reached and return empty iterator (default: 10 seconds)
Maximum cardinality matching
MolecularGraph.is_perfect_matching
— Methodis_perfect_matching(G::SimpleGraph) -> Bool
is_perfect_matching(G::SimpleGraph, matching::Set{Int}) -> Bool
Return if the given graph has a perfect matching.
MolecularGraph.max_matching
— Methodmax_matching(G::SimpleGraph; method=:Blossom) -> Set{Int}
Compute maximum cardinality matching by Edmonds' blossom algorithm and return the set of matched edges.
Graph operations
MolecularGraph.induced_subgraph_edges
— Methodinduced_subgraph_edges(g, node_list)
Return the node-induced subgraph edges.
MolecularGraph.line_graph
— Methodline_graph(G::SimpleGraph) -> SimpleGraph, Dict, Dict
Generate line graph, reverse mapping lg(v) -> g(e) and shared nodes mapping lg(e) -> g(v)
MolecularGraph.modular_product
— Methodmodularproduct(g::SimpleGraph{T}, h::SimpleGraph{T};
vmatch=(g1,h1)->true,
edgefilter=(g1,g2,h1,h2)->has_edge(g,g1,g2)==has_edge(g,h1,h2)) where T
Return the modular product m
of graphs g
and h
, and a mapping whether the edge is connected or not. mapping g,h nodes to m nods is f(i, j) = (i - 1) * nv(h) + j and the reverse mapping is f(i) = (div(i - 1, nv(h)) + 1, mod(i - 1, nv(h))) + 1, where i in g and j in h.
Planarity
MolecularGraph.isouterplanar
— Methodisouterplanar(graph::SimpleGraph) -> Bool
Return whether the graph is outerplanar. The outerplanarity test is based on a planarity test (see isplanar
).
MolecularGraph.isplanar
— Methodisplanar(graph::SimpleGraph) -> Bool
Return whether the graph is planar.
Reference
- de Fraysseix, H., & Ossona de Mendez, P. (2012). Trémaux trees and planarity. European Journal of Combinatorics, 33(3), 279–293. https://doi.org/10.1016/j.ejc.2011.09.012
- Trémaux trees and planarity. https://arxiv.org/abs/math/0610935