Class LineGraphBuilder
Utility to construct a line graph by connecting vertices by Id instead of index, which is far more convenient when building a custom editor. As an example use case, this class is used to construct the LineGraph by the LineGraph.
Namespace: AnyPath.Graphs.Line
Assembly: AnyPath.dll
Syntax
public class LineGraphBuilder
Remarks
Also have a look at LineGraphDrawer which is simpler to use
Constructors
LineGraphBuilder()
Declaration
public LineGraphBuilder()
Methods
Clear()
Clear the builder.
Declaration
public void Clear()
ContainsVertex(int)
Check if a vertex has been added
Declaration
public bool ContainsVertex(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| bool |
GetData(out List<float3>, out List<Edge>, out List<Edge>)
Convert this representation to a representation suitable to construct the line graph.
Declaration
public void GetData(out List<float3> verts, out List<LineGraph.Edge> undirectedIndices, out List<LineGraph.Edge> directedIndices)
Parameters
| Type | Name | Description |
|---|---|---|
| List<float3> | verts | |
| List<LineGraph.Edge> | undirectedIndices | |
| List<LineGraph.Edge> | directedIndices |
GetVertex(int)
Returns the position of the vertex with a given Id
Declaration
public float3 GetVertex(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| float3 |
LinkDirected(int, int)
Links two vertices together creating a traversable edge only from a to b
Declaration
public void LinkDirected(int a, int b)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | |
| int | b |
LinkDirected(int, int, float, int, int)
Links two vertices together creating a traversable edge only from a to b
Declaration
public void LinkDirected(int a, int b, float enterCost, int flags = 0, int id = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | Id of vertex A |
| int | b | Id of vertex B |
| float | enterCost | Additional cost associated with entering this edge in a path |
| int | flags | Flags that can be used to filter the edge being traversable |
| int | id | Optional user defined Id that is given to the edge. This Id can be used for obtaining the edge from the LineGraph that is constructed |
LinkUndirected(int, int)
Links two vertices together creating a traversable edge in both directions
Declaration
public int LinkUndirected(int a, int b)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | |
| int | b |
Returns
| Type | Description |
|---|---|
| int | The index of the edge in the internal list of edges |
LinkUndirected(int, int, float, int, int)
Links two vertices together creating a traversable edge in both directions
Declaration
public int LinkUndirected(int a, int b, float enterCost, int flags = 0, int id = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | a | Id of vertex A |
| int | b | Id of vertex B |
| float | enterCost | Additional cost associated with entering this edge in a path |
| int | flags | Flags that can be used to filter the edge being traversable |
| int | id | Optional user defined Id that is given to the edge. This Id can be used for obtaining the edge from the LineGraph that is constructed |
Returns
| Type | Description |
|---|---|
| int | The index of the edge in the internal list of edges |
SetVertex(int, float3)
Assigns a position to a vertex Id. If the vertex Id doesn't exist yet, it will be created. Otherwise it will be overwritten.
Declaration
public void SetVertex(int id, float3 pos)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| float3 | pos |