java.lang.Object
org.jgrapht.alg.isomorphism.IsomorphicGraphMapping<V,E>
- Type Parameters:
V
- the type of the verticesE
- the type of the edges
- All Implemented Interfaces:
GraphMapping<V,
E>
This class represents a GraphMapping between two (subgraph)isomorphic graphs. In the subgraph
isomorphic case, the second one is assumed to be a subgraph of the first one.
- Author:
- Fabian Späh, Alexandru Valeanu
-
Field Summary
-
Constructor Summary
ConstructorDescriptionIsomorphicGraphMapping
(Map<V, V> forwardMapping, Map<V, V> backwardMapping, Graph<V, E> graph1, Graph<V, E> graph2) Construct a new isomorphic graph mapping.IsomorphicGraphMapping
(org.jgrapht.alg.isomorphism.GraphOrdering<V, E> g1, org.jgrapht.alg.isomorphism.GraphOrdering<V, E> g2, int[] core1, int[] core2) Construct a new isomorphic graph mapping -
Method Summary
Modifier and TypeMethodDescriptioncompose
(IsomorphicGraphMapping<V, E> otherMapping) Computes the composition of two isomorphisms.boolean
Get an unmodifiable version of the backward mapping function.getEdgeCorrespondence
(E e, boolean forward) Gets the mapped value where the key isedge
Get an unmodifiable version of the forward mapping function.Get the active domain of the isomorphism.Get the range of the isomorphism.getVertexCorrespondence
(V v, boolean forward) Gets the mapped value where the key isvertex
boolean
Checks if a edge e from the first graph has a corresponding edge in the second graphint
hashCode()
boolean
Checks if a vertex $v$ from the first graph has a corresponding vertex in the second graphstatic <V,
E> IsomorphicGraphMapping<V, E> Computes an identity automorphism (i.e.boolean
isEqualMapping
(GraphMapping<V, E> rel) Checks for equality.boolean
Determines whether this mapping is indeed a valid isomorphic mapping between the first graph and the second graph.toString()
-
Field Details
-
NULL_NODE
public static final int NULL_NODE- See Also:
-
-
Constructor Details
-
IsomorphicGraphMapping
public IsomorphicGraphMapping(org.jgrapht.alg.isomorphism.GraphOrdering<V, E> g1, org.jgrapht.alg.isomorphism.GraphOrdering<V, E> g2, int[] core1, int[] core2) Construct a new isomorphic graph mapping- Parameters:
g1
- the first graphg2
- the second graph which is a possible subgraph of g1core1
- the mapping as array (forwards)core2
- the mapping as array (backwards)
-
IsomorphicGraphMapping
public IsomorphicGraphMapping(Map<V, V> forwardMapping, Map<V, V> backwardMapping, Graph<V, E> graph1, Graph<V, E> graph2) Construct a new isomorphic graph mapping.- Parameters:
forwardMapping
- the mapping from graph1 to graph2backwardMapping
- the mapping from graph2 to graph1 (inverse of forwardMapping)graph1
- the first graphgraph2
- the second graph
-
-
Method Details
-
getVertexCorrespondence
Description copied from interface:GraphMapping
Gets the mapped value where the key isvertex
- Specified by:
getVertexCorrespondence
in interfaceGraphMapping<V,
E> - Parameters:
v
- vertex in one of the graphsforward
- if true, uses mapping from graph1 to graph2; if false, use mapping from graph2 to graph1- Returns:
- corresponding vertex in other graph, or null if none
-
getEdgeCorrespondence
Description copied from interface:GraphMapping
Gets the mapped value where the key isedge
- Specified by:
getEdgeCorrespondence
in interfaceGraphMapping<V,
E> - Parameters:
e
- edge in one of the graphsforward
- if true, uses mapping from graph1 to graph2; if false, use mapping from graph2 to graph1- Returns:
- corresponding edge in other graph, or null if none
-
getForwardMapping
Get an unmodifiable version of the forward mapping function.- Returns:
- the unmodifiable forward mapping function
-
getBackwardMapping
Get an unmodifiable version of the backward mapping function.- Returns:
- the unmodifiable backward mapping function
-
getMappingDomain
Get the active domain of the isomorphism.- Returns:
- the set of vertices $v$ for which the mapping is defined
-
getMappingRange
Get the range of the isomorphism.- Returns:
- the set of vertices $v$ for which a preimage exists
-
hasVertexCorrespondence
Checks if a vertex $v$ from the first graph has a corresponding vertex in the second graph- Parameters:
v
- the vertex- Returns:
- is there a corresponding vertex to $v$ in the subgraph
-
hasEdgeCorrespondence
Checks if a edge e from the first graph has a corresponding edge in the second graph- Parameters:
e
- the edge- Returns:
- is there a corresponding edge to $e$ in the subgraph
-
equals
-
hashCode
public int hashCode() -
toString
-
isValidIsomorphism
public boolean isValidIsomorphism()Determines whether this mapping is indeed a valid isomorphic mapping between the first graph and the second graph. Note that this method will return false for a homomorphism returned by a subgraph isomorphism inspector unless the resulting mapping happens to be bijective as well (mapping all of the vertices and edges from the first graph to the second graph and vice versa).- Returns:
- true iff this mapping is a valid isomorphism between the two graphs
-
isEqualMapping
Checks for equality. Assuming both are mappings on the same graphs.- Parameters:
rel
- the corresponding mapping- Returns:
- do both relations map to the same vertices
-
compose
Computes the composition of two isomorphisms. Let $f : V_{G_1} \rightarrow V_{G_2}$ be an isomorphism from $V_{G_1}$ to $V_{G_2}$ and $g : V_{G_2} \rightarrow V_{G_3}$ one from $V_{G_2}$ to $V_{G_3}$. This method computes an isomorphism $h : V_{G_1} \rightarrow V_{G_3}$ from $V_{G_1}$ to $V_{G_3}$. Note: The composition $g ∘ f$ can be built only if $f$'s codomain equals $g$'s domain; this implementation only requires that the former is a subset of the latter.- Parameters:
otherMapping
- the other isomorphism (i.e. function $g$)- Returns:
- the composition of the two isomorphism
-
identity
Computes an identity automorphism (i.e. a self-mapping of a graph in which each vertex also maps to itself).- Type Parameters:
V
- the graph vertex typeE
- the graph edge type- Parameters:
graph
- the input graph- Returns:
- a mapping from graph to graph
-