public static Graph MakeHub(int childrenCount) { Graph graph = new Graph(); graph.AddNode(new BaseNode()); graph.AddChildren( childrenCount, 0 ); return graph; }
public static Graph MakeString(int nodeCount) { Graph graph = new Graph(); graph.AddNode(new BaseNode()); for (int i = 1; i < nodeCount; ++i) { graph.AddNode(new BaseNode()); graph.AddEdge(graph.NodeCount - 2, graph.NodeCount - 1); } return graph; }
void setBuffers(Graph graph) { foreach (BaseNode n in graph.Nodes) { if (n is SpatialNode) { addNode(n.GetSize(), n.GetColor(), ((SpatialNode)n).Position); } else { addNode(n.GetSize(), n.GetColor()); } } foreach (var e in graph.Edges) { addEdge(e.End1, e.End2, e.Length, e.Value); } setBuffers(); }
public void UpdateGraph(Graph graph) { nodeList.Clear(); edgeList.Clear(); edgeIndexLists.Clear(); setBuffers(graph); }
public Graph GetGraph() { if (lay.CurrentStateBuffer != null) { Particle3d[] particleArray = new Particle3d[lay.ParticleCount]; lay.CurrentStateBuffer.GetData(particleArray); Graph graph = new Graph(); foreach (var p in particleArray) { graph.AddNode(new SpatialNode(p.Position, p.Size, new Color(p.Color))); } foreach (var l in edgeList) { graph.AddEdge(new Graph.Edge((int)l.par1, (int)l.par2, l.length, l.strength)); } return graph; } return new Graph(); }
public void AddGraph(Graph graph) { lay.ResetState(); nodeList.Clear(); edgeList.Clear(); edgeIndexLists.Clear(); referenceNodeIndex = 0; setBuffers( graph ); }
public static Graph MakeTree(int nodeCount, int arity) { Graph graph = new Graph(); graph.AddNode(new BaseNode()); graph.AddChildren(arity, graph.NodeCount - 1); Queue<int> latestIndex = new Queue<int>(); for (int i = 0; i < arity; ++i) { latestIndex.Enqueue(graph.NodeCount - 1 - i); } while (graph.NodeCount < nodeCount) { if (latestIndex.Count <= 0) { break; } int parentIndex = latestIndex.Peek(); if (graph.adjacencyList[parentIndex].Count > arity) { latestIndex.Dequeue(); continue; } graph.AddChildren(1, parentIndex); latestIndex.Enqueue(graph.NodeCount - 1); } return graph; }