Navigation
API > API/Plugins > API/Plugins/GameplayGraph > API/Plugins/GameplayGraph/Graph
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UGraph
References
| Module | GameplayGraph |
| Header | /Engine/Plugins/Experimental/GameplayGraph/Source/GameplayGraph/Public/Graph/Graph.h |
| Include | #include "Graph/Graph.h" |
Syntax
UCLASS&40;&41;
class UGraph : public UObject
Remarks
A UGraph is a collection of nodes and edges. This graph representation is meant to be easily integrable into gameplay systems in the Unreal Engine.
Conceptually, you can imagine that a graph is meant to easily represent relationships so we can answer queries such as:
- Are these two nodes connected to each other?
- How far away are these two nodes?
- Who is the closest node that has XYZ?
- etc.
UGraph provides an interface to be able to run such queries. However, ultimately what makes the graph useful is not only the relationships represented by the edges, but also the data that is stored on each node and each edge. Depending on what the user wants to represent, the user will have to subclass UGraphVertex and UGraphEdge to hold that data.
As the user adds nodes and edges into the graph, they will also be implicitly creating "islands" (i.e. a connected component in the graph). Each graph may have multiple islands. Users of the graph can disable the island detection/creation if needed.
Note that this is an UNDIRECTED GRAPH.
Variables
| Type | Name | Description | |
|---|---|---|---|
| FOnGraphEdgeCreated | OnEdgeCreated | ||
| FOnGraphIslandCreated | OnIslandCreated | ||
| FOnGraphVertexCreated | OnVertexCreated |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UGraph () |
Functions
| Type | Name | Description | |
|---|---|---|---|
| FGraphEdgeHandle | CreateEdge
(
FGraphVertexHandle Node1, |
Creates an edge between the two nodes. | |
| FGraphVertexHandle | CreateVertex
(
int64 InUniqueIndex |
Create a node with the specified subclass, adds it to the graph, and returns a handle to it. | |
| void | Empty () |
||
| void | FinalizeVertex
(
const FGraphVertexHandle& InHandle |
This should be called immediately after a node and any relevant edges have been added to the graph. | |
| FGraphVertexHandle | GetCompleteNodeHandle
(
const FGraphVertexHandle& InHandle |
Given a node handle, find the handle in the current graph with a proper element set. | |
| const TMap< FGraphEdgeHandle, TObjectPtr< UGraphEdge > > & | GetEdges () |
||
| const TMap< FGraphIslandHandle, TObjectPtr< UGraphIsland > > & | GetIslands () |
||
| const FGraphProperties & | |||
| FSerializableGraph | |||
| const TMap< FGraphVertexHandle, TObjectPtr< UGraphVertex > > & | GetVertices () |
||
| void | InitializeFromProperties
(
const FGraphProperties& Properties |
||
| void | LoadFromSerializedGraph
(
const FSerializableGraph& Input |
||
| int32 | NumEdges () |
||
| int32 | NumIslands () |
||
| int32 | NumVertices () |
||
| void | RemoveEdge
(
const FGraphEdgeHandle& EdgeHandle, |
Removes an edge from the graph. | |
| void | RemoveIsland
(
const FGraphIslandHandle& IslandHandle |
Remove an island from the graph. | |
| void | RemoveVertex
(
const FGraphVertexHandle& NodeHandle |
Removes a node from the graph along with any edges that contain it. |