or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

abstract-base-classes.mddirected-graphs.mdindex.mdmixed-graphs.mdspecialized-graphs.mdtree-structures.mdundirected-graphs.mdutilities.md
tile.json

tessl/maven-net-sf-jung--jung-graph-impl

Graph implementations for the JUNG project - provides concrete implementations of graph data structures for the Java Universal Network/Graph Framework

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/net.sf.jung/jung-graph-impl@2.1.x

To install, run

npx @tessl/cli install tessl/maven-net-sf-jung--jung-graph-impl@2.1.0

index.mddocs/

JUNG Graph Implementation

JUNG (Java Universal Network/Graph Framework) Graph Implementation provides concrete data structure implementations for graph modeling, analysis, and visualization. This module offers high-performance sparse graph implementations including directed graphs, undirected graphs, multigraphs, trees, hypergraphs, and specialized ordered variants optimized for network analysis and scientific computing applications.

Package Information

  • Package Name: jung-graph-impl
  • Package Type: Maven
  • Language: Java
  • Installation:
    <dependency>
      <groupId>net.sf.jung</groupId>
      <artifactId>jung-graph-impl</artifactId>
      <version>2.1.1</version>
    </dependency>

Core Imports

import edu.uci.ics.jung.graph.*;

Common specific imports:

import edu.uci.ics.jung.graph.DirectedSparseGraph;
import edu.uci.ics.jung.graph.UndirectedSparseGraph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.graph.SortedSparseMultigraph;
import edu.uci.ics.jung.graph.DelegateTree;
import edu.uci.ics.jung.graph.SetHypergraph;
import java.util.Comparator;

Basic Usage

import edu.uci.ics.jung.graph.DirectedSparseGraph;
import edu.uci.ics.jung.graph.Graph;

// Create a directed graph
Graph<String, String> directedGraph = new DirectedSparseGraph<>();

// Add vertices
directedGraph.addVertex("A");
directedGraph.addVertex("B");
directedGraph.addVertex("C");

// Add edges
directedGraph.addEdge("edge1", "A", "B");
directedGraph.addEdge("edge2", "B", "C");

// Query the graph
System.out.println("Vertices: " + directedGraph.getVertices());
System.out.println("Edges: " + directedGraph.getEdges());
System.out.println("Neighbors of B: " + directedGraph.getNeighbors("B"));
System.out.println("Successors of A: " + directedGraph.getSuccessors("A"));

Architecture

JUNG Graph Implementation is organized around several key architectural patterns:

  • Abstract Base Classes: AbstractGraph and AbstractTypedGraph provide common functionality and enforce consistent interfaces across implementations
  • Graph Type Specialization: Separate implementations for directed, undirected, and mixed edge type graphs
  • Sparse Graph Optimization: All implementations are optimized for sparse graphs (few edges relative to possible edges)
  • Parallel Edge Support: Multigraph variants support multiple edges between the same vertex pair
  • Ordering Preservation: Ordered variants maintain insertion order for vertices and edges
  • Tree Structures: Specialized tree implementations with parent-child relationships and hierarchical operations
  • Hypergraph Support: Implementation for edges connecting multiple vertices simultaneously
  • Factory Pattern: Static factory methods provide consistent object creation across implementations

Capabilities

Abstract Base Classes

Foundation classes that provide common graph functionality and establish consistent interfaces across all graph implementations.

public abstract class AbstractGraph<V,E> implements Graph<V,E>, Serializable {
    public boolean addEdge(E edge, Collection<? extends V> vertices);
    public boolean addEdge(E e, V v1, V v2);
    public abstract boolean addEdge(E edge, Pair<? extends V> endpoints, EdgeType edgeType);
}

public abstract class AbstractTypedGraph<V,E> extends AbstractGraph<V,E> {
    public AbstractTypedGraph(EdgeType edge_type);
    public EdgeType getDefaultEdgeType();
    public EdgeType getEdgeType(E e);
}

Abstract Base Classes

Directed Graph Implementations

Specialized graph implementations for directed relationships where edges have a source vertex and destination vertex.

public class DirectedSparseGraph<V,E> extends AbstractTypedGraph<V,E> implements DirectedGraph<V,E> {
    public DirectedSparseGraph();
    public static <V,E> Supplier<DirectedGraph<V,E>> getFactory();
}

public class DirectedSparseMultigraph<V,E> extends AbstractTypedGraph<V,E> 
    implements DirectedGraph<V,E>, MultiGraph<V,E> {
    public DirectedSparseMultigraph();
    public static <V,E> Supplier<DirectedGraph<V,E>> getFactory();
}

Directed Graphs

Undirected Graph Implementations

Graph implementations for symmetric relationships where edges connect vertices without directional preference.

public class UndirectedSparseGraph<V,E> extends AbstractTypedGraph<V,E> implements UndirectedGraph<V,E> {
    public UndirectedSparseGraph();
    public static <V,E> Supplier<UndirectedGraph<V,E>> getFactory();
}

public class UndirectedSparseMultigraph<V,E> extends AbstractTypedGraph<V,E> 
    implements UndirectedGraph<V,E>, MultiGraph<V,E> {
    public UndirectedSparseMultigraph();
    public static <V,E> Supplier<UndirectedGraph<V,E>> getFactory();
}

Undirected Graphs

Mixed Graph Implementations

General-purpose graph implementations supporting both directed and undirected edges within the same graph structure.

public class SparseGraph<V,E> extends AbstractGraph<V,E> implements Graph<V,E> {
    public SparseGraph();
    public static <V,E> Supplier<Graph<V,E>> getFactory();
}

public class SparseMultigraph<V,E> extends AbstractGraph<V,E> implements MultiGraph<V,E> {
    public SparseMultigraph();
    public static <V,E> Supplier<Graph<V,E>> getFactory();
}

Mixed Graphs

Tree Implementations

Specialized hierarchical graph structures with parent-child relationships and tree-specific operations.

public class DelegateTree<V,E> extends GraphDecorator<V,E> implements Tree<V,E> {
    public DelegateTree();
    public static <V,E> Supplier<Tree<V,E>> getFactory();
    public V getRoot();
    public Collection<V> getChildren(V parent);
}

public class DelegateForest<V,E> extends GraphDecorator<V,E> implements Forest<V,E> {
    public DelegateForest();
    public Collection<V> getRoots();
    public Collection<Tree<V,E>> getTrees();
}

Tree Structures

Specialized Graph Types

Advanced graph implementations for specific use cases including hypergraphs, ordered structures, and sorted graphs.

public class SetHypergraph<V,H> implements Hypergraph<V,H>, MultiGraph<V,H>, Serializable {
    public SetHypergraph();
    public static <V,H> Supplier<Hypergraph<V,H>> getFactory();
    public boolean addEdge(H hyperedge, Collection<? extends V> to_attach);
}

public class OrderedKAryTree<V,E> extends AbstractTypedGraph<V,E> implements Tree<V,E> {
    public OrderedKAryTree(int order);
    public V getChild(V vertex, int index);
}

public class SortedSparseMultigraph<V,E> extends OrderedSparseMultigraph<V,E> implements MultiGraph<V,E> {
    public SortedSparseMultigraph();
    public SortedSparseMultigraph(Comparator<V> vertex_comparator, Comparator<E> edge_comparator);
    public static <V,E> Supplier<Graph<V,E>> getFactory();
}

public class DirectedOrderedSparseMultigraph<V,E> extends DirectedSparseMultigraph<V,E> 
    implements DirectedGraph<V,E>, MultiGraph<V,E> {
    public DirectedOrderedSparseMultigraph();
    public static <V,E> Supplier<DirectedGraph<V,E>> getFactory();
}

public class UndirectedOrderedSparseMultigraph<V,E> extends UndirectedSparseMultigraph<V,E> 
    implements UndirectedGraph<V,E>, MultiGraph<V,E> {
    public UndirectedOrderedSparseMultigraph();
    public static <V,E> Supplier<UndirectedGraph<V,E>> getFactory();
}

Specialized Graphs

Utility Classes

Helper classes providing graph generation and testing utilities for development and testing purposes.

public class TestGraphs {
    public static Graph<String, Number> createTestGraph(boolean directed);
    public static Graph<String,Number> getOneComponentGraph();
    public static Graph<String, Number> getDemoGraph();
}

Utilities

Common Types

// Core interfaces from jung-api (referenced but not implemented in this module)
interface Hypergraph<V,E> {
    Collection<E> getEdges();
    Collection<V> getVertices();
    boolean containsVertex(V vertex);
    boolean containsEdge(E edge);
    int getEdgeCount();
    int getVertexCount();
    Collection<V> getNeighbors(V vertex);
    Collection<E> getIncidentEdges(V vertex);
    Collection<V> getIncidentVertices(E edge);
    E findEdge(V v1, V v2);
    Collection<E> findEdgeSet(V v1, V v2);
    boolean addVertex(V vertex);
    boolean removeVertex(V vertex);
    boolean addEdge(E edge, Collection<? extends V> vertices);
    boolean removeEdge(E edge);
}

interface Graph<V,E> extends Hypergraph<V,E> {
    Collection<E> getInEdges(V vertex);
    Collection<E> getOutEdges(V vertex);
    Collection<V> getPredecessors(V vertex);
    Collection<V> getSuccessors(V vertex);
    int inDegree(V vertex);
    int outDegree(V vertex);
    boolean isPredecessor(V v1, V v2);
    boolean isSuccessor(V v1, V v2);
    int getPredecessorCount(V vertex);
    int getSuccessorCount(V vertex);
    V getSource(E directed_edge);
    V getDest(E directed_edge);
    boolean isSource(V vertex, E edge);
    boolean isDest(V vertex, E edge);
}

interface DirectedGraph<V,E> extends Graph<V,E> {
    // Specialized directed graph interface
}

interface UndirectedGraph<V,E> extends Graph<V,E> {
    // Specialized undirected graph interface
}

interface MultiGraph<V,E> extends Graph<V,E> {
    // Allows multiple edges between same vertex pair
}

interface Tree<V,E> extends Graph<V,E> {
    V getRoot();
    Collection<V> getChildren(V vertex);
    V getParent(V vertex);
    int getDepth(V vertex);
    int getHeight();
}

interface Forest<V,E> extends Graph<V,E> {
    Collection<V> getRoots();
    Collection<Tree<V,E>> getTrees();
}

// Utility classes
class Pair<T> {
    public T getFirst();
    public T getSecond();
    public static <T> Pair<T> create(T first, T second);
}

enum EdgeType {
    DIRECTED, UNDIRECTED
}

// Abstract base classes (implemented in this module)
abstract class AbstractGraph<V,E> implements Graph<V,E>, Serializable {
    public boolean addEdge(E edge, Collection<? extends V> vertices);
    public boolean addEdge(E e, V v1, V v2);
    public abstract boolean addEdge(E edge, Pair<? extends V> endpoints, EdgeType edgeType);
}

abstract class AbstractTypedGraph<V,E> extends AbstractGraph<V,E> {
    public AbstractTypedGraph(EdgeType edge_type);
    public EdgeType getDefaultEdgeType();
    public EdgeType getEdgeType(E e);
}