Class JungAdapter

java.lang.Object
it.unimi.dsi.webgraph.jung.JungAdapter
All Implemented Interfaces:
edu.uci.ics.jung.graph.DirectedGraph<Integer,​Long>, edu.uci.ics.jung.graph.Graph<Integer,​Long>, edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>

public class JungAdapter
extends Object
implements edu.uci.ics.jung.graph.DirectedGraph<Integer,​Long>
An adapter exposing an ImmutableGraph as a Jung DirectedGraph.

Using this adapter it is easy to apply Jung's analysis and visualisation code to immutable graphs.

Edges are just Longs, and their values are the index of the source node, shifted to the left by 32 bits, OR'd with the index of the target node.

The main method of this class provides a simple way to translate any immutable graph in Pajek format.

  • Constructor Details

  • Method Details

    • getSource

      public Integer getSource​(Long e)
      Specified by:
      getSource in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      getSource in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getDest

      public Integer getDest​(Long e)
      Specified by:
      getDest in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      getDest in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getEndpoints

      public edu.uci.ics.jung.graph.util.Pair<Integer> getEndpoints​(Long e)
      Specified by:
      getEndpoints in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • getInEdges

      public Collection<Long> getInEdges​(Integer x)
      Specified by:
      getInEdges in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      getInEdges in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getOpposite

      public Integer getOpposite​(Integer v, Long e)
      Specified by:
      getOpposite in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • getOutEdges

      public Collection<Long> getOutEdges​(Integer x)
      Specified by:
      getOutEdges in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      getOutEdges in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getPredecessorCount

      public int getPredecessorCount​(Integer x)
      Specified by:
      getPredecessorCount in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • getPredecessors

      public Collection<Integer> getPredecessors​(Integer x)
      Specified by:
      getPredecessors in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      getPredecessors in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getSuccessorCount

      public int getSuccessorCount​(Integer x)
      Specified by:
      getSuccessorCount in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • getSuccessors

      public Collection<Integer> getSuccessors​(Integer x)
      Specified by:
      getSuccessors in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      getSuccessors in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • inDegree

      public int inDegree​(Integer x)
      Specified by:
      inDegree in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      inDegree in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • isDest

      public boolean isDest​(Integer v, Long e)
      Specified by:
      isDest in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • isArc

      public boolean isArc​(int x, int y)
    • isPredecessor

      public boolean isPredecessor​(Integer x, Integer y)
      Specified by:
      isPredecessor in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • isSource

      public boolean isSource​(Integer v, Long e)
      Specified by:
      isSource in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • isSuccessor

      public boolean isSuccessor​(Integer x, Integer y)
      Specified by:
      isSuccessor in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
    • outDegree

      public int outDegree​(Integer x)
      Specified by:
      outDegree in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Specified by:
      outDegree in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • containsEdge

      public boolean containsEdge​(Long e)
      Specified by:
      containsEdge in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • containsVertex

      public boolean containsVertex​(Integer x)
      Specified by:
      containsVertex in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • degree

      public int degree​(Integer x)
      Specified by:
      degree in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • findEdge

      public Long findEdge​(Integer x, Integer y)
      Specified by:
      findEdge in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • findEdgeSet

      public Collection<Long> findEdgeSet​(Integer x, Integer y)
      Specified by:
      findEdgeSet in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getDefaultEdgeType

      public edu.uci.ics.jung.graph.util.EdgeType getDefaultEdgeType()
      Specified by:
      getDefaultEdgeType in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getEdgeCount

      public int getEdgeCount()
      Specified by:
      getEdgeCount in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getEdgeCount

      public int getEdgeCount​(edu.uci.ics.jung.graph.util.EdgeType x)
      Specified by:
      getEdgeCount in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getEdgeType

      public edu.uci.ics.jung.graph.util.EdgeType getEdgeType​(Long e)
      Specified by:
      getEdgeType in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getEdges

      public Collection<Long> getEdges()
      Specified by:
      getEdges in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getEdges

      public Collection<Long> getEdges​(edu.uci.ics.jung.graph.util.EdgeType x)
      Specified by:
      getEdges in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getIncidentCount

      public int getIncidentCount​(Long e)
      Specified by:
      getIncidentCount in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getIncidentEdges

      public Collection<Long> getIncidentEdges​(Integer x)
      Specified by:
      getIncidentEdges in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getIncidentVertices

      public Collection<Integer> getIncidentVertices​(Long e)
      Specified by:
      getIncidentVertices in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getNeighborCount

      public int getNeighborCount​(Integer x)
      Specified by:
      getNeighborCount in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getNeighbors

      public Collection<Integer> getNeighbors​(Integer x)
      Specified by:
      getNeighbors in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getVertexCount

      public int getVertexCount()
      Specified by:
      getVertexCount in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • getVertices

      public Collection<Integer> getVertices()
      Specified by:
      getVertices in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • isIncident

      public boolean isIncident​(Integer x, Long e)
      Specified by:
      isIncident in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • isNeighbor

      public boolean isNeighbor​(Integer x, Integer y)
      Specified by:
      isNeighbor in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
    • removeEdge

      public boolean removeEdge​(Long e)
      Specified by:
      removeEdge in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • removeVertex

      public boolean removeVertex​(Integer x)
      Specified by:
      removeVertex in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • addEdge

      public boolean addEdge​(Long e, Integer y, Integer arg2)
      Specified by:
      addEdge in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • addEdge

      public boolean addEdge​(Long e, Integer y, Integer arg2, edu.uci.ics.jung.graph.util.EdgeType arg3)
      Specified by:
      addEdge in interface edu.uci.ics.jung.graph.Graph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • addEdge

      public boolean addEdge​(Long e, Collection<? extends Integer> y)
      Specified by:
      addEdge in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • addEdge

      public boolean addEdge​(Long e, Collection<? extends Integer> y, edu.uci.ics.jung.graph.util.EdgeType arg2)
      Specified by:
      addEdge in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • addVertex

      public boolean addVertex​(Integer x)
      Specified by:
      addVertex in interface edu.uci.ics.jung.graph.Hypergraph<Integer,​Long>
      Throws:
      UnsupportedOperationException
    • main

      public static void main​(String[] arg) throws IOException, JSAPException
      Throws:
      IOException
      JSAPException