Click or drag to resize
AcyclicLP Class

The AcyclicLP class represents a data type for solving the single-source longest paths problem in edge-weighted directed acyclic graphs (DAGs). The edge weights can be positive, negative, or zero.

This implementation uses a topological-sort based algorithm. The constructor takes time proportional to V + E, where V is the number of vertices and E is the number of edges. Afterwards, the DistTo() and HasPathTo() methods take constant time and the PathTo() method takes time proportional to the number of edges in the longest path returned.

Inheritance Hierarchy
SystemObject
  Algs4NetAcyclicLP

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class AcyclicLP

The AcyclicLP type exposes the following members.

Constructors
  NameDescription
Public methodAcyclicLP
Computes a longest paths tree from s to every other vertex in the directed acyclic graph G.
Top
Methods
  NameDescription
Public methodDistTo
Returns the length of a longest path from the source vertex s to vertex v.
Public methodHasPathTo
Is there a path from the source vertex s to vertex v?
Public methodStatic memberMainTest
Demo test the AcyclicLP data type.
Public methodPathTo
Returns a longest path from the source vertex s to vertex v.
Top
Remarks

For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class AcyclicLP implementation by the respective authors.

See Also