static void Main(string[] args) { string file = "rosalind_ddeg"; UndirectedGraph g = new UndirectedGraph(file + ".txt"); int[] res = Rosalind.GetSumNeighborsDegree(g); Utils.PrintArrayToFile(res, file + ".out.txt"); Utils.Finish(); }
static public int[] GetVerticesDegree(UndirectedGraph g) { int[] res = new int[g.CountVertices]; for (int v = 0; v < g.CountVertices; v++) { res[v] = Algorithms.Degree(g, v); } return res; }
static public int[] GetSumNeighborsDegree(UndirectedGraph g) { int[] res = new int[g.CountVertices]; for (int v = 0; v < g.CountVertices; v++) { //res[v] = 0; foreach (int n in g.g[v]) { res[v] += Algorithms.Degree(g, n); } } return res; }
static public int Degree(UndirectedGraph g, int v) { return(g.g[v].Count); }
static public int Degree(UndirectedGraph g, int v) { return g.g[v].Count; }