Graph ClassDelta Engine Documentation
Basis for path finding with A-Star, usually used via LevelGraph for 2D maps. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.GameLogic.PathFinding Graph
    DeltaEngine.GameLogic.PathFinding LevelGraph

Namespace: DeltaEngine.GameLogic.PathFinding
Assembly: DeltaEngine.GameLogic.PathFinding (in DeltaEngine.GameLogic.PathFinding.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class Graph

The Graph type exposes the following members.

Constructors

  NameDescription
Public methodGraph
Initializes a new instance of the Graph class
Top
Methods

  NameDescription
Public methodConnect
Public methodGetNode
Public methodIsConnected
Protected methodIsInvalidNodeId
Top
Properties

  NameDescription
Public propertyAdjacentLinks
Public propertyNodes
Public propertyNumberOfNodes
Top
Remarks

Tests: DeltaEngine.GameLogic.PathFinding.Tests.GraphTests
Examples

5 unit tests call DeltaEngine.GameLogic.PathFinding.Graph
[Test]
public void ThrowExceptionISearchedForWrongNode()
{
    Assert.Throws<Graph.InvalidNodeId>(() => graphAsPlusShape.GetNode(-1));
}
[Test]
public void CheckForExistingGraphNodes()
{
    for (int nodeId = 0; nodeId < NumberOfNodesInGraph; nodeId++)
        Assert.IsNotNull(graphAsPlusShape.GetNode(nodeId));
}
[Test]
public void CheckForConnectedNodes()
{
    Assert.IsTrue(graphAsPlusShape.IsConnected(2, 0));
    Assert.IsTrue(graphAsPlusShape.IsConnected(0, 2));
    Assert.IsTrue(graphAsPlusShape.IsConnected(2, 1));
    Assert.IsTrue(graphAsPlusShape.IsConnected(1, 2));
    Assert.IsTrue(graphAsPlusShape.IsConnected(2, 3));
    Assert.IsTrue(graphAsPlusShape.IsConnected(3, 2));
    Assert.IsTrue(graphAsPlusShape.IsConnected(2, 4));
    Assert.IsTrue(graphAsPlusShape.IsConnected(4, 2));
}
See Also