Aetheria/Assets/Scripts/NIH/MSAGL/GraphmapsWithMesh/Network.cs
hyperion51 01a956eef6 MSAGL Support
Added new tech tree layout implementation using Microsoft Automatic Graph Layouts
Added some functionality to the database editor tools
2020-04-14 00:42:04 +01:00

53 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.Msagl.GraphmapsWithMesh
{
public class Network
{
public List<Twin> Edges = new List<Twin>();
public int N;
public int E;
public int[,] M;
public Network(int numV, int numE, bool Random)
{
N = numV;
E = numE;
#if SHARPKIT //https://code.google.com/p/sharpkit/issues/detail?id=340
throw new InvalidOperationException();
#else
M = new int[numV + 1, numV + 1];
#endif
}
public Network(int numV, int numE)
{
N = numV;
#if SHARPKIT //https://code.google.com/p/sharpkit/issues/detail?id=340
throw new InvalidOperationException();
#else
M = new int[numV + 1, numV + 1];
#endif
int v2;
while (E < numE)
{
Random r = new Random();
var v1 = r.Next(1, numV);
v2 = r.Next(1, numV);
if (v1 == v2) continue;
var newEdge = Edges.All(x => (v1 != x.A || v2 != x.B) && (v1 != x.B || v2 != x.A));
if (newEdge)
{
E++;
Edges.Add(new Twin(v1, v2));
M[v1, v2] = 1;
M[v2, v1] = 1;
}
//Console.WriteLine(E);
}
}
}
}