docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Graph<T>

    Generic directed graph with traversal and analysis helpers.

    Inheritance
    object
    Graph<T>
    DependencyGraph
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: AutoGroupGenerator
    Assembly: Unity.AutoGroupGenerator.Editor.dll
    Syntax
    [Serializable]
    public class Graph<T> where T : IEquatable<T>
    Type Parameters
    Name Description
    T

    The node value type stored in the graph.

    Constructors

    Name Description
    Graph()

    Initializes an empty graph.

    Fields

    Name Description
    _adjacencyList

    Adjacency list mapping nodes to outgoing neighbors.

    Properties

    Name Description
    NodeCount

    Gets the number of nodes in the graph.

    Methods

    Name Description
    AddEdge(T, T)

    Adds an edge between two nodes, adding missing nodes as needed.

    AddNode(T)

    Adds a node to the graph if it does not already exist.

    BreadthFirstSearch(T, Action<T>)

    Performs a breadth-first traversal starting at the given node.

    CollapseToSCCs()

    Collapses strongly connected components into a DAG of SuperNode instances.

    ConvertNodeType<TResult>(Func<T, TResult>)

    Converts the graph to use a different node type.

    DepthFirstSearch(T, Action<T>)

    Performs a depth-first traversal starting at the given node.

    DepthFirstSearchForAllPaths(T, Predicate<T>)

    Finds all paths from a start node to nodes matching a condition.

    DepthFirstSearchForAllPaths(T, T)

    Finds all paths between a start and end node using DFS.

    DepthFirstSearchIterative(T, HashSet<T>, Action<T>)

    Performs a depth-first traversal with a provided visited set.

    FindAllPathsToLeafNodes(T)

    Finds all paths from the start node to any leaf node.

    FindLeafNodes(T)

    Finds all leaf nodes reachable from the given node.

    FindPathAndLeaves(T, out HashSet<T>, out HashSet<T>)

    Finds nodes along paths from the starting node and the leaf nodes reached.

    FindPathConeToLeaves(T)

    Finds every node along paths from the starting node to leaves.

    FromSerializableData(SerializableData)

    Rehydrates a graph from serialized data.

    GetAllNodes()

    Gets all nodes in the graph.

    GetConnectedComponentsOfUndirectedGraph(Graph<T>)

    Returns the connected components of an undirected graph.

    GetNeighbors(T)

    Gets the neighbors for the specified node.

    GetSubgraph(List<T>)

    Creates a subgraph containing only the specified nodes.

    GetTransposedGraph()

    Builds the transposed graph with all edges reversed.

    RemoveNodeFromUndirectedGraph(Graph<T>, T)

    Removes a node and its edges from an undirected graph.

    ToSerializableData()

    Serializes the graph into a data transfer object.

    ToUndirected(Graph<T>)

    Converts a directed graph into an undirected graph by mirroring edges.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)