Show / Hide Table of Contents

    Class Network<T>

    A network composed of nodes and edges with associated data. A network does not store spatial information. A network can index into another collection of entities which have a spatial context.

    Inheritance
    System.Object
    Network<T>
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements.Search
    Assembly: Hypar.Elements.dll
    Syntax
    public class Network<T>
    Type Parameters
    Name Description
    T

    The type of data associated with the graph's edges.

    Constructors

    Network()

    Create a network.

    Declaration
    public Network()

    Methods

    AddEdgeBothWays(Int32, Int32, T)

    Adds edges to the network both ways from->to and to->from.

    Declaration
    public void AddEdgeBothWays(int from, int to, T data)
    Parameters
    Type Name Description
    System.Int32 from

    The index of the start node.

    System.Int32 to

    The index of the end node.

    T data

    The data associated with the edge.

    AddEdgeOneWay(Int32, Int32, T)

    Adds an edge to the network from->to.

    Declaration
    public void AddEdgeOneWay(int from, int to, T data)
    Parameters
    Type Name Description
    System.Int32 from

    The index of the start node.

    System.Int32 to

    The index of the end node.

    T data

    The data associated with the edge.

    AddVertex()

    Add a vertex to the network.

    Declaration
    public int AddVertex()
    Returns
    Type Description
    System.Int32

    BranchNodes()

    All branch nodes of the network.

    Declaration
    public List<int> BranchNodes()
    Returns
    Type Description
    System.Collections.Generic.List<System.Int32>

    A collection of branch node indices.

    EdgesAt(Int32)

    Get all edges at the specified index.

    Declaration
    public IEnumerable<(int, T)> EdgesAt(int i)
    Parameters
    Type Name Description
    System.Int32 i

    The index.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.ValueTuple<System.Int32, T>>

    FindAllClosedRegions(List<Vector3>)

    Find all the closed regions in the network. This method uses the Traverse method internally with a traversal function that uses the maximal plane angle to determine the direction of traversal.

    Declaration
    public List<List<int>> FindAllClosedRegions(List<Vector3> allNodeLocations)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Vector3> allNodeLocations

    A collection of all node locations in the network.

    Returns
    Type Description
    System.Collections.Generic.List<System.Collections.Generic.List<System.Int32>>

    A collection of integers representing the indices of the nodes forming closed regions in the network.

    FromSegmentableItems(IList<T>, Func<T, Line>, out List<Vector3>, out List<Vector3>, Boolean)

    Construct a network from the intersections of a collection of items which provide segments in a shared plane.

    Declaration
    public static Network<T> FromSegmentableItems(IList<T> items, Func<T, Line> getSegment, out List<Vector3> allNodeLocations, out List<Vector3> allIntersectionLocations, bool twoWayEdges = true)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<T> items

    A collection of segmentable items.

    System.Func<T, Line> getSegment

    A delegate which returns a segment from an item of type T.

    System.Collections.Generic.List<Vector3> allNodeLocations

    A collection of all node locations.

    System.Collections.Generic.List<Vector3> allIntersectionLocations

    A collection of all intersection locations.

    System.Boolean twoWayEdges

    Should edges be created in both directions?

    Returns
    Type Description
    Network<T>

    A network.

    LeafNodes()

    All leaf nodes of the network.

    Declaration
    public List<int> LeafNodes()
    Returns
    Type Description
    System.Collections.Generic.List<System.Int32>

    A collection of leaf node indices.

    NodeCount()

    The total number of nodes in the network.

    Declaration
    public int NodeCount()
    Returns
    Type Description
    System.Int32

    ToBoundedAreaPanels(List<Vector3>)

    Draw bounded areas of the network as panels.

    Declaration
    public List<Panel> ToBoundedAreaPanels(List<Vector3> allNodeLocations)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Vector3> allNodeLocations

    All node locations in the network.

    Returns
    Type Description
    System.Collections.Generic.List<Panel>

    ToModelArrows(IList<Vector3>, Nullable<Color>)

    Draw the network as model arrows.

    Declaration
    public ModelArrows ToModelArrows(IList<Vector3> nodeLocations, Color? color)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Vector3> nodeLocations

    The locations of the network's nodes.

    System.Nullable<Color> color

    The color of the resulting model geometry.

    Returns
    Type Description
    ModelArrows

    ToModelCurves(List<Vector3>)

    Draw the network as model curves.

    Declaration
    public List<ModelCurve> ToModelCurves(List<Vector3> nodeLocations)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Vector3> nodeLocations
    Returns
    Type Description
    System.Collections.Generic.List<ModelCurve>

    ToModelText(List<Vector3>, Color)

    Draw node indices and connected node indices at each node.

    Declaration
    public List<ModelText> ToModelText(List<Vector3> nodeLocations, Color color)
    Parameters
    Type Name Description
    System.Collections.Generic.List<Vector3> nodeLocations

    A collection of node locations.

    Color color

    The color of the model text.

    Returns
    Type Description
    System.Collections.Generic.List<ModelText>

    Traverse(Int32, Func<(Int32, Int32, IEnumerable<Int32>), List<Vector3>, List<LocalEdge>, Int32>, List<Vector3>, List<LocalEdge>, out List<Int32>, Int32)

    Traverse the network from the specified node index. Traversal concludes when there are no more available nodes to traverse.

    Declaration
    public List<int> Traverse(int start, Func<(int, int, IEnumerable<int>), List<Vector3>, List<LocalEdge>, int> next, List<Vector3> allNodeLocations, List<LocalEdge> visitedEdges, out List<int> visited, int prevIndex = -1)
    Parameters
    Type Name Description
    System.Int32 start

    The starting point of the traversal.

    System.Func<System.ValueTuple<System.Int32, System.Int32, System.Collections.Generic.IEnumerable<System.Int32>>, System.Collections.Generic.List<Vector3>, System.Collections.Generic.List<LocalEdge>, System.Int32> next

    The traversal step delegate.

    System.Collections.Generic.List<Vector3> allNodeLocations

    A collection of all node locations in the network.

    System.Collections.Generic.List<LocalEdge> visitedEdges

    A collection of all visited edges.

    System.Collections.Generic.List<System.Int32> visited

    A collection of visited node indices.

    System.Int32 prevIndex

    The previous index found during the traversal

    Returns
    Type Description
    System.Collections.Generic.List<System.Int32>

    A list of indices of the traversed nodes.

    TraverseLargestPlaneAngle((Int32 currentIndex, Int32 previousIndex, IEnumerable<Int32> edgeIndices), List<Vector3>, List<LocalEdge>)

    Traverse a network following the smallest plane angle between the current edge and the next candidate edge.

    Declaration
    public static int TraverseLargestPlaneAngle((int currentIndex, int previousIndex, IEnumerable<int> edgeIndices) traversalData, List<Vector3> allNodeLocations, List<LocalEdge> visitedEdges)
    Parameters
    Type Name Description
    System.ValueTuple<System.Int32, System.Int32, System.Collections.Generic.IEnumerable<System.Int32>> traversalData

    Data about the current step of the traversal.

    System.Collections.Generic.List<Vector3> allNodeLocations

    A collection of all node locations in the network.

    System.Collections.Generic.List<LocalEdge> visitedEdges

    A collection of previously visited edges.

    Returns
    Type Description
    System.Int32

    The next index to traverse.

    TraverseSmallestPlaneAngle((Int32 currentIndex, Int32 previousIndex, IEnumerable<Int32> edgeIndices), List<Vector3>, List<LocalEdge>)

    Traverse a network following the smallest plane angle between the current edge and the next candidate edge.

    Declaration
    public static int TraverseSmallestPlaneAngle((int currentIndex, int previousIndex, IEnumerable<int> edgeIndices) traversalData, List<Vector3> allNodeLocations, List<LocalEdge> visitedEdges)
    Parameters
    Type Name Description
    System.ValueTuple<System.Int32, System.Int32, System.Collections.Generic.IEnumerable<System.Int32>> traversalData

    Data about the current step of the traversal.

    System.Collections.Generic.List<Vector3> allNodeLocations

    A collection of all node locations in the network.

    System.Collections.Generic.List<LocalEdge> visitedEdges

    A collection of previously visited edges.

    Returns
    Type Description
    System.Int32

    The next index to traverse.