Class Graph.Edge<N,E extends Number>

java.lang.Object
util.collection.Graph.Edge<N,E>
Type Parameters:
N - the type of nodes
E - the type of edge weight, must extend Number
Enclosing class:
Graph<N,E extends Number>

public static class Graph.Edge<N,E extends Number> extends Object
Edge represents a connection between two nodes in the graph, possibly with a weight and additional properties.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Edge(N from, N to)
    Constructs an edge with specified nodes, no weight or properties.
    Edge(N from, N to, E weight)
    Constructs an edge with specified nodes and weight, no properties.
    Edge(N from, N to, E weight, Map<String,?> properties)
    Constructs an edge with specified nodes, weight, and properties.
    Edge(N from, N to, Map<String,?> properties)
    Constructs an edge with specified nodes and properties, no weight.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the source node of the edge.
    <T> T
    getProperty(String property, Class<T> clazz)
    Returns the value of a property for this edge, cast to the specified type.
    Returns the destination node of the edge.
    double
    Returns the weight of the edge as a double.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Edge

      public Edge(N from, N to, E weight, Map<String,?> properties)
      Constructs an edge with specified nodes, weight, and properties.
      Parameters:
      from - the source node
      to - the destination node
      weight - the weight of the edge
      properties - additional properties for the edge
    • Edge

      public Edge(N from, N to, Map<String,?> properties)
      Constructs an edge with specified nodes and properties, no weight.
      Parameters:
      from - the source node
      to - the destination node
      properties - additional properties for the edge
    • Edge

      public Edge(N from, N to, E weight)
      Constructs an edge with specified nodes and weight, no properties.
      Parameters:
      from - the source node
      to - the destination node
      weight - the weight of the edge
    • Edge

      public Edge(N from, N to)
      Constructs an edge with specified nodes, no weight or properties.
      Parameters:
      from - the source node
      to - the destination node
  • Method Details

    • getFrom

      public N getFrom()
      Returns the source node of the edge.
      Returns:
      the source node
    • getTo

      public N getTo()
      Returns the destination node of the edge.
      Returns:
      the destination node
    • getWeight

      public double getWeight()
      Returns the weight of the edge as a double.
      Returns:
      the weight of the edge as a double, or 0.0 if the weight is null
    • getProperty

      public <T> T getProperty(String property, Class<T> clazz)
      Returns the value of a property for this edge, cast to the specified type.
      Type Parameters:
      T - the type of the property value
      Parameters:
      property - the property name
      clazz - the class of the property value
      Returns:
      the property value cast to the specified type