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 ()
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 | ||
| FOnGraphEdgeRemoved | OnEdgeRemoved | ||
| FOnGraphIslandCreated | OnIslandCreated | ||
| FOnGraphVertexCreated | OnVertexCreated |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UGraph () |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | ChangeVertexHandle
(
const FGraphVertexHandle& OldVertexHandle, |
Changes a node handle, updating all the references. The vertex must exist. | |
| void | CreateBulkEdges
(
TArray< FEdgeSpecifier >&& NodesToConnect |
Creates edges in bulk. | |
| FGraphVertexHandle | CreateVertex
(
FGraphUniqueIndex 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. | |
| void | ForEachIsland
(
TLambda&& Lambda |
||
| FGraphVertexHandle | GetCompleteNodeHandle
(
const FGraphVertexHandle& InHandle |
Given a node handle, find the handle in the current graph with a proper element set. | |
| const TMap< FGraphIslandHandle, TObjectPtr< UGraphIsland > > & | GetIslands () |
||
| const FGraphProperties & | |||
| UGraphIsland * | GetSafeIslandFromHandle
(
const FGraphIslandHandle& Handle |
||
| UGraphVertex * | GetSafeVertexFromHandle
(
const FGraphVertexHandle& Handle |
||
| const TMap< FGraphVertexHandle, TObjectPtr< UGraphVertex > > & | GetVertices () |
||
| void | InitializeFromProperties
(
const FGraphProperties& Properties |
||
| void | MergeOrCreateIslands
(
const TArray< FEdgeSpecifier >& InEdges |
When we add multiple edges into the graph. | |
| int32 | NumIslands () |
||
| int32 | NumVertices () |
||
| void | RefreshIslandConnectivity
(
const FGraphIslandHandle& IslandHandle |
Refresh the connectivity of the given island (re-check to see whether it should be split). | |
| void | RemoveBulkVertices
(
const TArray< FGraphVertexHandle >& InHandles |
||
| void | RemoveIsland
(
const FGraphIslandHandle& IslandHandle |
Remove an island from the graph. | |
| void | RemoveOrSplitIsland
(
TObjectPtr< UGraphIsland > Island |
After a change, this function will remove the island if it's empty or will attempt to split it into two smaller islands. | |
| void | RemoveVertex
(
const FGraphVertexHandle& NodeHandle |
Removes a node from the graph along with any edges that contain it. | |
| void | ReserveIslands
(
int32 Delta |
||
| void | ReserveVertices
(
int32 Delta |
Used for bulk loading in vertices/edges/islands. |