Aetheria/Assets/Plugins/MSAGL/Layout/Layered/Layering/LongestPathLayering.cs
Reinier Vens dbc522a224 Weapos Rejiggered
Modified weapon scripts to eliminate specialized projectile behavior - allows charged weapons to have projectiles and modify weapon stats when charged
Added machine gun weapon & VFX
Moved third party code to Plugins folder to improve compile times
2021-01-31 03:52:32 +00:00

43 lines
1.1 KiB
C#

#region Using directives
#endregion
using Microsoft.Msagl.Core.GraphAlgorithms;
using Microsoft.Msagl.Core.Layout;
namespace Microsoft.Msagl.Layout.Layered {
/// <summary>
/// Layering the DAG by longest path
/// </summary>
internal class LongestPathLayering : LayerCalculator {
BasicGraph<IntEdge> graph;
public int[] GetLayers() {
//sort the vertices in topological order
int[] topoOrder = IntEdge.GetOrder(graph);
int[] layering = new int[graph.NodeCount];
//going backward from leaves
int k = graph.NodeCount;
while (k-- > 0) {
int v = topoOrder[k];
foreach (IntEdge e in graph.InEdges(v)) {
int u = e.Source;
int l = layering[v] + e.Separation;
if (layering[u] < l)
layering[u] = l;
}
}
return layering;
}
internal LongestPathLayering(BasicGraph<IntEdge> graph){
this.graph=graph;
}
}
}