algraph-0.7.0.0: Graph library using adjacency list representation
CopyrightThodoris Papakonstantinou 2017-2026
LicenseLGPL-3
Maintainerdev@tpapak.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Graph.AdjacencyList.DFS

Description

Depth-first search (DFS) on directed graphs. Produces a topological ordering, a visited-order list, and the set of discovered vertices. Also provides longestPath on DAGs and connectivity queries.

Synopsis

Documentation

data DFS Source #

Result of a depth-first search from a single source vertex.

Constructors

DFS 

Fields

Instances

Instances details
Show DFS Source # 
Instance details

Defined in Data.Graph.AdjacencyList.DFS

Methods

showsPrec :: Int -> DFS -> ShowS #

show :: DFS -> String #

showList :: [DFS] -> ShowS #

Eq DFS Source # 
Instance details

Defined in Data.Graph.AdjacencyList.DFS

Methods

(==) :: DFS -> DFS -> Bool #

(/=) :: DFS -> DFS -> Bool #

dfs :: Graph -> Vertex -> DFS Source #

Depth first search

Types

type DAG = Graph Source #

:)

type Distances = IntMap Vertex Source #

Map from vertex to its distance (number of edges) from the source in a DAG.

get longest path from a vertex to another

longestPath :: Graph -> Vertex -> Vertex -> [Edge] Source #

Longest path from tail to nose

postordering :: DFS -> [Vertex] Source #

Post-order traversal (reverse of topsort).

areConnected :: Distances -> Vertex -> Vertex -> Bool Source #

Check whether vertex v is reachable from vertex u according to the given distance map (distance > 0 means reachable; u is reachable from itself).

distances :: DAG -> DFS -> Vertex -> Distances Source #

Ginen a DAG and a vertex you get the distances