Rebornbuddy
Loading...
Searching...
No Matches
Pathfinding.Graph Class Reference

Graph structure. It is defined with : It is defined with both a list of nodes and a list of arcs. More...

Public Member Functions

Node NodeById (int id)
IEnumerable< NodeSearch (Vector3 loc, float maxRange)
IEnumerable< NodeSearch (Node loc, float maxRange)
 Graph ()
 Constructor.
void Clear ()
 Empties the graph.
bool AddNode (Node NewNode)
 Directly Adds a node to the graph.
Node AddNode (float x, float y, float z)
 Creates a node, adds to the graph and returns its reference.
Node AddNode (float x, float y, float z, int id, int[] ignore)
 Creates a node, adds to the graph and returns its reference.
Node AddNode (Vector3 xyz, int id, int[] ignore)
 Creates a node, adds to the graph and returns its reference.
List< int > FreeIds (int wanted)
bool AddArc (Arc NewArc)
 Directly Adds an arc to the graph.
Arc AddArc (Node StartNode, Node EndNode, float Weight)
 Creates an arc between two nodes that are already registered in the graph, adds it to the graph and returns its reference.
void Add2Arcs (Node Node1, Node Node2, float Weight)
 Adds the two opposite arcs between both specified nodes to the graph.
Node FindClosest (Vector3 loc, Predicate< Node > predicate=null)
bool RemoveNode (Node NodeToRemove)
 Removes a node from the graph as well as the linked arcs.
void RemoveAllArcs ()
bool RemoveArc (Arc ArcToRemove)
 Removes a node from the graph as well as the linked arcs.
Node ClosestNode (float PtX, float PtY, float PtZ, out float Distance, bool IgnorePassableProperty)
 This function will find the closest node from a geographical position in space.
Node CloestNode (Vector3 point)
Node ClosestNode (Vector3 point, out float Distance, bool IgnorePassableProperty)
Node ClosestNode2D (Vector3 point)
Arc ClosestArc2D (Vector3 point, out float distance)
List< CloseNodeClosestNodes (Vector3 point, int desiredNodes, bool IgnorePassableProperty)
 returns the three closest nodes to a point
List< CloseNodeFarthestNodes (Vector3 point, int desiredNodes, bool IgnorePassableProperty)
 returns the three closest nodes to a point
Node FarthestNode (float PtX, float PtY, float PtZ, out float Distance, bool IgnorePassableProperty)
 This function will find the farthest node from a geographical position in space.

Properties

Node this[int key] [get]
Dictionary< int, NodeNodes [get, set]
 Gets the List interface of the nodes in the graph.
HashSet< ArcArcs [get]
 Gets the List interface of the arcs in the graph.
int freeId [get]

Detailed Description

Graph structure. It is defined with : It is defined with both a list of nodes and a list of arcs.

Constructor & Destructor Documentation

◆ Graph()

Pathfinding.Graph.Graph ( )

Constructor.

Member Function Documentation

◆ Add2Arcs()

void Pathfinding.Graph.Add2Arcs ( Node Node1,
Node Node2,
float Weight )

Adds the two opposite arcs between both specified nodes to the graph.

Exceptions
ArgumentExceptionCannot add an arc if one of its extremity nodes does not belong to the graph.
Parameters
Node1
Node2
Weight

◆ AddArc() [1/2]

bool Pathfinding.Graph.AddArc ( Arc NewArc)

Directly Adds an arc to the graph.

Exceptions
ArgumentExceptionCannot add an arc if one of its extremity nodes does not belong to the graph.
Parameters
NewArcThe arc to add.
Returns
'true' if it has actually been added / 'false' if the arc is null or if it is already in the graph.

◆ AddArc() [2/2]

Arc Pathfinding.Graph.AddArc ( Node StartNode,
Node EndNode,
float Weight )

Creates an arc between two nodes that are already registered in the graph, adds it to the graph and returns its reference.

Exceptions
ArgumentExceptionCannot add an arc if one of its extremity nodes does not belong to the graph.
Parameters
StartNodeStart node for the arc.
EndNodeEnd node for the arc.
WeightWeight for the arc.
Returns
The reference of the new arc / null if the arc is already in the graph.

◆ AddNode() [1/4]

Node Pathfinding.Graph.AddNode ( float x,
float y,
float z )

Creates a node, adds to the graph and returns its reference.

Parameters
xX coordinate.
yY coordinate.
zZ coordinate.
Returns
The reference of the new node / null if the node is already in the graph.

◆ AddNode() [2/4]

Node Pathfinding.Graph.AddNode ( float x,
float y,
float z,
int id,
int[] ignore )

Creates a node, adds to the graph and returns its reference.

Parameters
xX coordinate.
yY coordinate.
zZ coordinate.
idId of the node
Returns
The reference of the new node / null if the node is already in the graph.

◆ AddNode() [3/4]

bool Pathfinding.Graph.AddNode ( Node NewNode)

Directly Adds a node to the graph.

Parameters
NewNodeThe node to add.
Returns
'true' if it has actually been added / 'false' if the node is null or if it is already in the graph.

◆ AddNode() [4/4]

Node Pathfinding.Graph.AddNode ( Vector3 xyz,
int id,
int[] ignore )

Creates a node, adds to the graph and returns its reference.

Parameters
xX coordinate.
yY coordinate.
zZ coordinate.
idId of the node
Returns
The reference of the new node / null if the node is already in the graph.

◆ Clear()

void Pathfinding.Graph.Clear ( )

Empties the graph.

◆ CloestNode()

Node Pathfinding.Graph.CloestNode ( Vector3 point)

◆ ClosestArc2D()

Arc Pathfinding.Graph.ClosestArc2D ( Vector3 point,
out float distance )

◆ ClosestNode() [1/2]

Node Pathfinding.Graph.ClosestNode ( float PtX,
float PtY,
float PtZ,
out float Distance,
bool IgnorePassableProperty )

This function will find the closest node from a geographical position in space.

Parameters
PtXX coordinate of the point from which you want the closest node.
PtYY coordinate of the point from which you want the closest node.
PtZZ coordinate of the point from which you want the closest node.
DistanceThe distance to the closest node.
IgnorePassablePropertyif 'false', then nodes whose property Passable is set to false will not be taken into account.
Returns
The closest node that has been found.

◆ ClosestNode() [2/2]

Node Pathfinding.Graph.ClosestNode ( Vector3 point,
out float Distance,
bool IgnorePassableProperty )

◆ ClosestNode2D()

Node Pathfinding.Graph.ClosestNode2D ( Vector3 point)

◆ ClosestNodes()

List< CloseNode > Pathfinding.Graph.ClosestNodes ( Vector3 point,
int desiredNodes,
bool IgnorePassableProperty )

returns the three closest nodes to a point

Parameters
point
IgnorePassableProperty
Returns

◆ FarthestNode()

Node Pathfinding.Graph.FarthestNode ( float PtX,
float PtY,
float PtZ,
out float Distance,
bool IgnorePassableProperty )

This function will find the farthest node from a geographical position in space.

Parameters
PtXX coordinate of the point from which you want the closest node.
PtYY coordinate of the point from which you want the closest node.
PtZZ coordinate of the point from which you want the closest node.
DistanceThe distance to the closest node.
IgnorePassablePropertyif 'false', then nodes whose property Passable is set to false will not be taken into account.
Returns
The closest node that has been found.

◆ FarthestNodes()

List< CloseNode > Pathfinding.Graph.FarthestNodes ( Vector3 point,
int desiredNodes,
bool IgnorePassableProperty )

returns the three closest nodes to a point

Parameters
point
IgnorePassableProperty
Returns

◆ FindClosest()

Node Pathfinding.Graph.FindClosest ( Vector3 loc,
Predicate< Node > predicate = null )

◆ FreeIds()

List< int > Pathfinding.Graph.FreeIds ( int wanted)

◆ NodeById()

Node Pathfinding.Graph.NodeById ( int id)

◆ RemoveAllArcs()

void Pathfinding.Graph.RemoveAllArcs ( )

◆ RemoveArc()

bool Pathfinding.Graph.RemoveArc ( Arc ArcToRemove)

Removes a node from the graph as well as the linked arcs.

Parameters
ArcToRemoveThe arc to remove.
Returns
'true' if succeeded / 'false' otherwise.

◆ RemoveNode()

bool Pathfinding.Graph.RemoveNode ( Node NodeToRemove)

Removes a node from the graph as well as the linked arcs.

Parameters
NodeToRemoveThe node to remove.
Returns
'true' if succeeded / 'false' otherwise.

◆ Search() [1/2]

IEnumerable< Node > Pathfinding.Graph.Search ( Node loc,
float maxRange )

◆ Search() [2/2]

IEnumerable< Node > Pathfinding.Graph.Search ( Vector3 loc,
float maxRange )

Property Documentation

◆ Arcs

HashSet<Arc> Pathfinding.Graph.Arcs
get

Gets the List interface of the arcs in the graph.

◆ freeId

int Pathfinding.Graph.freeId
get

◆ Nodes

Dictionary<int, Node> Pathfinding.Graph.Nodes
getset

Gets the List interface of the nodes in the graph.

◆ this[int key]

Node Pathfinding.Graph.this[int key]
get