Loading...
Searching...
No Matches
digraph Type Reference

Definition

Directed graph with fixed vertex count and efficient cycle detection Stores edges in a dense adjacency matrix slice per vertex. Only the actually used portion of each row is tracked via list_sizes.

Constructor interface for digraph type.

Examples

type(digraph) :: g
logical :: cycle
g = digraph(3) ! 3 macros indexed 1..3
call g%add_edge(1, 2) ! macro1 depends on macro2
call g%add_edge(2, 3) ! macro2 depends on macro3
call g%add_edge(3, 1) ! macro3 depends on macro1 → cycle!
cycle = g%is_circular(1) ! returns .true.
print *, 'Circular macro chain detected:', cycle
...

Constructors

Initializes a new instance of the digraph class

digraph(integer)

type(digraph) function digraph(integer vertices) 
Parameters
[in]verticesNumber of vertices (usually number of currently defined macros)

Examples

type(digraph) :: g
g = digraph(3)
Returns
The constructed digraph object.

Remarks

Remarks

Definition at line 96 of file graph.f90.


The documentation for this type was generated from the following file:

Private Attributes

integer, private vertices
 Number of vertices.
 
integer, dimension(:, :), allocatable, private adjacency_list
 Adjacency list containing the connection information between the vertices.
 
integer, dimension(:), allocatable, private list_sizes
 Actually used portion of each row of adjacency_list.
 

Methods

◆ add_edge()

procedure, pass, public add_edge ( class(digraph), intent(inout) this,
integer, intent(in) source,
integer, intent(in) destination,
logical, intent(out), optional exists )

Add a directed edge from source → destination Silently ignores invalid indices. Optional exists flag indicates if edge was already present.

Parameters
[in,out]thisdigraph object
[in]sourceSource vertex (1-based)
[in]destinationTarget vertex (1-based)
[out]exists(optional) .true. if edge already existed

Remarks

Definition at line 87 of file graph.f90.

◆ is_circular()

procedure, pass, public is_circular ( class(digraph), intent(in) this,
integer, intent(in) start_vertex )

Check whether a cycle exists in the graph reachable from start_vertex Uses standard DFS with recursion stack (back-edge detection).

Parameters
[in]thisdigraph object
[in]start_vertexVertex from which to begin cycle search
Returns
.true. if a cycle is found in the component reachable from start_vertex

Remarks

Definition at line 88 of file graph.f90.

Constructor & Destructor Documentation

◆ graph_final()

final graph_final ( type(digraph), intent(inout) this)
final

Finalizer – automatically deallocate internal arrays when graph goes out of scope.

Definition at line 89 of file graph.f90.