Class DefaultGraphMapping<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type
    All Implemented Interfaces:
    GraphMapping<V,​E>

    public class DefaultGraphMapping<V,​E>
    extends Object
    implements GraphMapping<V,​E>
    Implementation of the GraphMapping interface. The performance of getVertex/EdgeCorrespondence is based on the performance of the concrete Map class which is passed in the constructor. For example, using HashMap will provide expected $O(1)$ performance.
    Author:
    Assaf Lehr
    • Constructor Detail

      • DefaultGraphMapping

        public DefaultGraphMapping​(Map<V,​V> g1ToG2,
                                   Map<V,​V> g2ToG1,
                                   Graph<V,​E> g1,
                                   Graph<V,​E> g2)
        The maps themselves are used. There is no defensive-copy. Assumption: The key and value in the mappings are of valid graph objects. It is not checked.
        Parameters:
        g1ToG2 - vertex mapping from the first graph to the second
        g2ToG1 - vertex mapping from the second graph to the first
        g1 - the first graph
        g2 - the second graph
    • Method Detail

      • getEdgeCorrespondence

        public E getEdgeCorrespondence​(E currEdge,
                                       boolean forward)
        Description copied from interface: GraphMapping
        Gets the mapped value where the key is edge
        Specified by:
        getEdgeCorrespondence in interface GraphMapping<V,​E>
        Parameters:
        currEdge - edge in one of the graphs
        forward - 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
      • getVertexCorrespondence

        public V getVertexCorrespondence​(V keyVertex,
                                         boolean forward)
        Description copied from interface: GraphMapping
        Gets the mapped value where the key is vertex
        Specified by:
        getVertexCorrespondence in interface GraphMapping<V,​E>
        Parameters:
        keyVertex - vertex in one of the graphs
        forward - 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