KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
SpanningTree Class Reference

A Dijkstra-based spanning tree for finding shortest paths through a line network. More...

#include <spanningtree.h>

Public Member Functions

 SpanningTree ()
 Default constructor — creates an empty, invalid spanning tree.
 
 SpanningTree (const Line::List &lines)
 Construct a SpanningTree from a network of line segments.
 
virtual ~SpanningTree ()
 Destructor — frees all dynamically allocated vertex objects.
 
Line::List computePath ()
 Compute the shortest path from origin to destination through the line network.
 
void setOrigin (const QPointF &origin, Geo::Direction preferredDirection=Geo::NoDirection)
 Set the origin point from which to route.
 
void setDestination (const QPointF &destination)
 Set the destination point to route towards.
 
TreePathVertice::List vertices () const
 Return all vertices in the spanning tree.
 
bool isValid () const
 Return true if the spanning tree contains at least one line segment.
 

Detailed Description

A Dijkstra-based spanning tree for finding shortest paths through a line network.

Computes the shortest path through a network of Line segments using Dijkstra's algorithm.

Construct with a Line::List representing the navigable network, set the origin and destination points, then call computePath() to retrieve the ordered list of lines that form the shortest route.

Definition at line 16 of file spanningtree.h.

Constructor & Destructor Documentation

◆ SpanningTree() [1/2]

SpanningTree::SpanningTree ( )
inline

Default constructor — creates an empty, invalid spanning tree.

Definition at line 20 of file spanningtree.h.

◆ SpanningTree() [2/2]

SpanningTree::SpanningTree ( const Line::List lines)

Construct a SpanningTree from a network of line segments.

Parameters
linesLine segments forming the navigable graph

Member Function Documentation

◆ computePath()

Line::List SpanningTree::computePath ( )

Compute the shortest path from origin to destination through the line network.

Returns
Ordered list of lines forming the path, or an empty list if no path exists

◆ isValid()

bool SpanningTree::isValid ( ) const
inline

Return true if the spanning tree contains at least one line segment.

Returns
true if the line network is non-empty

Definition at line 64 of file spanningtree.h.

◆ setDestination()

void SpanningTree::setDestination ( const QPointF &  destination)

Set the destination point to route towards.

Parameters
destinationTarget point in the line network's coordinate space

◆ setOrigin()

void SpanningTree::setOrigin ( const QPointF &  origin,
Geo::Direction  preferredDirection = Geo::NoDirection 
)

Set the origin point from which to route.

Parameters
originStarting point in the line network's coordinate space
preferredDirectionInitial preferred travel direction (default NoDirection)

◆ vertices()

TreePathVertice::List SpanningTree::vertices ( ) const
inline

Return all vertices in the spanning tree.

Returns
List of all TreePathVertice objects in the graph

Definition at line 55 of file spanningtree.h.


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