Show / Hide Table of Contents

Class IDirectedAcyclicGraphExtensions

Wrapper for all extension methods essentially using the IDirectedAcyclicGraph interface.

Inheritance
Object
IDirectedAcyclicGraphExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Mangrove.MetricSetSyntaxTree.Extensions
Assembly: MetricSetSyntaxTree.dll
Syntax
public static class IDirectedAcyclicGraphExtensions

Methods

View Source

AddClosure<T>(T, Stack<T>, Func<T, Boolean>, Action<T>)

Add the "closure" of node to a mystery collection, using provided methods to determine whether a node is contained in the collection, and to add a method to the collection.

Declaration
public static void AddClosure<T>(this T node, Stack<T> stack, Func<T, bool> contains, Action<T> add)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T node
Stack<T> stack

The contents of this are ignored. It is required as a parameter to allow re-use of this collection for maximal performance.

Func<T, Boolean> contains
Action<T> add
Type Parameters
Name Description
T
Remarks

In the long run, the existing Closure<T>(IEnumerable<T>) methods should probably be refactored to use this method, which is likely more performant, given that it's non-recursive.

View Source

AddParents<T>(IDictionary<T, ISet<T>>, T)

Add the mappings parent -> key to dict. If any parents do not exist as keys, their values are updated as well.

Declaration
public static void AddParents<T>(this IDictionary<T, ISet<T>> dict, T key)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IDictionary<T, ISet<T>> dict
T key
Type Parameters
Name Description
T
View Source

Ancestors(Expression, Boolean)

All direct and indirect parents of expr. If idempotent is set to true, the result will include expr itself.

Declaration
public static ISet<Expression> Ancestors(this Expression expr, bool idempotent = false)
Parameters
Type Name Description
Expression expr
Boolean idempotent
Returns
Type Description
ISet<Expression>
View Source

Ancestors(Table, Boolean)

All direct and indirect parents of table. If idempotent is set to true, the result will include table itself.

Declaration
public static ISet<Table> Ancestors(this Table table, bool idempotent = false)
Parameters
Type Name Description
Table table
Boolean idempotent
Returns
Type Description
ISet<Table>
View Source

Closure(Expression)

All nodes which are either expression, or a direct / indirect parent (ancestor) of expression.

Declaration
public static ISet<Expression> Closure(this Expression expression)
Parameters
Type Name Description
Expression expression
Returns
Type Description
ISet<Expression>
View Source

Closure(IEnumerable<Expression>)

All nodes in expressions, along with their direct and indirect parents (ancestors).

Declaration
public static ISet<Expression> Closure(this IEnumerable<Expression> expressions)
Parameters
Type Name Description
IEnumerable<Expression> expressions
Returns
Type Description
ISet<Expression>
View Source

Closure<T>(T)

All nodes which are either t, or a direct / indirect parent (ancestor) of t.

Declaration
public static ISet<T> Closure<T>(this T t)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T t
Returns
Type Description
ISet<T>
Type Parameters
Name Description
T
View Source

Closure<T>(IEnumerable<T>)

All nodes in ts, along with their direct and indirect parents (ancestors).

Declaration
public static ISet<T> Closure<T>(this IEnumerable<T> ts)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IEnumerable<T> ts
Returns
Type Description
ISet<T>
Type Parameters
Name Description
T
View Source

DescendantLookup<T>(IEnumerable<T>)

Produce a mapping from all nodes in ts to the collection of nodes which have a given node as direct / indirect child (descendant).

Declaration
public static IDictionary<T, ISet<T>> DescendantLookup<T>(this IEnumerable<T> ts)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IEnumerable<T> ts
Returns
Type Description
IDictionary<T, ISet<T>>
Type Parameters
Name Description
T
View Source

DescendantsIn<T>(T, IEnumerable<T>)

All elements of candidates which are either equal to parent, or are a direct / indirect child of parent.

Declaration
public static ISet<T> DescendantsIn<T>(this T parent, IEnumerable<T> candidates)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T parent
IEnumerable<T> candidates
Returns
Type Description
ISet<T>
Type Parameters
Name Description
T
View Source

DescendantsIn<T>(IEnumerable<T>, IEnumerable<T>)

All elements of candidates which are in parents, or are direct / indirect children of an element of parents.

Declaration
public static ISet<T> DescendantsIn<T>(this IEnumerable<T> parents, IEnumerable<T> candidates)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IEnumerable<T> parents
IEnumerable<T> candidates
Returns
Type Description
ISet<T>
Type Parameters
Name Description
T
View Source

LargestParentCountWith<T>(IEnumerable<T>, Func<T, Boolean>)

Given a collection of nodes, map each of them to the maximum count of parent nodes that satisfy the condition. The maximum is taken over the counts for all the chains of parents of each node.

Declaration
public static IDictionary<T, int> LargestParentCountWith<T>(this IEnumerable<T> ts, Func<T, bool> condition)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IEnumerable<T> ts
Func<T, Boolean> condition
Returns
Type Description
IDictionary<T, Int32>
Type Parameters
Name Description
T
View Source

Leaves<T>(IEnumerable<T>)

All elements in ts which are not the parent of another element in ts.

Declaration
public static IEnumerable<T> Leaves<T>(this IEnumerable<T> ts)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IEnumerable<T> ts
Returns
Type Description
IEnumerable<T>
Type Parameters
Name Description
T
View Source

Ordered(Table)

All direct / indirect parents (ancestors) of t, ordered by dependency.

Declaration
public static IEnumerable<Table> Ordered(this Table t)
Parameters
Type Name Description
Table t
Returns
Type Description
IEnumerable<Table>
View Source

OrderedDescendants<T>(T, Func<T, IEnumerable<T>>)

Return the collection of descendants of node in linear order, using the provided function to lookup children. This is more performant than chaining together the "descendants in" and "ordered unique" methods naively whenever a speedier child-lookup method exists.

Declaration
public static IEnumerable<T> OrderedDescendants<T>(this T node, Func<T, IEnumerable<T>> children)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T node
Func<T, IEnumerable<T>> children
Returns
Type Description
IEnumerable<T>
Type Parameters
Name Description
T
View Source

OrderedUnique<T>(IEnumerable<T>, Boolean)

All distinct nodes in ts, ordered from child to parent as a linear extension of the original partial order.

Declaration
public static IReadOnlyCollection<T> OrderedUnique<T>(this IEnumerable<T> ts, bool includeClosure = true)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
IEnumerable<T> ts
Boolean includeClosure

Whether or not to include the closure of ts in the result.

Returns
Type Description
IReadOnlyCollection<T>
Type Parameters
Name Description
T
View Source

PathTo<T>(T, T)

Use depth-first search (DFS) to find a path start -> ... -> end, throwing an InvalidOperationException if none exists. This method does not guarantee to return the shortest path.

Declaration
public static IReadOnlyList<T> PathTo<T>(this T start, T end)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T start
T end
Returns
Type Description
IReadOnlyList<T>
Type Parameters
Name Description
T
View Source

TopParentsWith<T>(T, Func<T, Boolean>)

Set of closest parents of node that satisfy the condition condition.

Declaration
public static ISet<T> TopParentsWith<T>(this T node, Func<T, bool> condition)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T node
Func<T, Boolean> condition
Returns
Type Description
ISet<T>
Type Parameters
Name Description
T
View Source

ToPrettyString<T>(T, Int32, Int32)

Print a "pretty" string that encodes a cascade of nodes. This is useful in printing meaningful warning / error messages.

Declaration
public static string ToPrettyString<T>(this T t, int maxDepth = 2147483647, int startingDepth = 0)
    where T : IDirectedAcyclicGraph<T>
Parameters
Type Name Description
T t
Int32 maxDepth

Print at most this depth of parents.

Int32 startingDepth

Start by indenting everything by this many spaces.

Returns
Type Description
String
Type Parameters
Name Description
T
  • View Source
Back to top Generated by DocFX