/// <summary> /// Transforms the free graph into relationship matrix /// </summary> /// <param name="graph">The graph.</param> /// <returns></returns> public static aceRelationMatrix <freeGraphNodeBase, freeGraphNodeBase, Double> GetMatrix(this freeGraph graph) { List <freeGraphNodeBase> nodes = graph.nodes; aceRelationMatrix <freeGraphNodeBase, freeGraphNodeBase, Double> output = new aceRelationMatrix <freeGraphNodeBase, freeGraphNodeBase, Double>(nodes, nodes, 0); foreach (freeGraphNodeBase node in nodes) { var links = graph.GetLinks(node.name, true, true); foreach (freeGraphLinkBase link in links.links) { var nodeA = graph.GetNode(link.nodeNameA); var nodeB = graph.GetNode(link.nodeNameB); if (link.nodeNameA == node.name) { output[nodeA, nodeB] += link.weight; } else { output[nodeB, nodeA] += link.weight; } } } return(output); }