public int Compare(int x, int y) { if (x == y) { return(0); } int nidX = _loader.IdFromPos(x); int nidY = _loader.IdFromPos(y); int xDegree = _loader.InEdgeCount(nidX) + _loader.OutEdgeCount(nidX); int yDegree = _loader.InEdgeCount(nidY) + _loader.OutEdgeCount(nidY); return(xDegree < yDegree ? 1 : -1); }
// Sorts positions in _loader so their corresponding vertices run from // highest total degree to lowest public int Compare(int x, int y) { if (x == y) { return(0); } var vidX = _loader.IdFromPos(x); var vidY = _loader.IdFromPos(y); var xDegree = _loader.InEdgeCount(vidX) + _loader.OutEdgeCount(vidX); var yDegree = _loader.InEdgeCount(vidY) + _loader.OutEdgeCount(vidY); return(yDegree.CompareTo(xDegree)); }
internal VfnNode(IGraphLoader loader, int inodGraph, Dictionary <VfeNode, VfeNode> dctEdge, int[] mpInodGraphInodVf) { int nid = loader.IdFromPos(inodGraph); _objAttr = loader.GetNodeAttr(nid); _arvfeEdgeOut = new VfeNode[loader.OutEdgeCount(nid)]; _arvfeEdgeIn = new VfeNode[loader.InEdgeCount(nid)]; MakeEdges(loader, nid, dctEdge, mpInodGraphInodVf); }
internal VfVertex(IGraphLoader <TV, TE> loader, int ivtxGraph, Dictionary <VfEdge, VfEdge> dctEdge, List <int> mpIvtxGraphIvtxVf) { var vid = loader.IdFromPos(ivtxGraph); _attribute = loader.GetVertexAttr(vid); _outEdges = new VfEdge[loader.OutEdgeCount(vid)]; _inEdges = new VfEdge[loader.InEdgeCount(vid)]; MakeEdges(loader, vid, dctEdge, mpIvtxGraphIvtxVf); }
// Since we make edges both for incoming edges and outgoing edges every edge actually gets visited twice - once for it's incoming vertex // and once for it's outgoing vertex. The first time we actually create the edge and the second time we need to reference the edge // created the first time. dctEdge keeps track of previously created edges so we can find them on the second visit. It has to be // be maintained during the entire construction of the graph so it's created in the graph constructor and passed down a rather large // call chain to be used here. private void MakeOutEdges(IGraphLoader <TV, TE> loader, int vid, Dictionary <VfEdge, VfEdge> dctEdge, List <int> mpIvtxGraphIvtxVf, ref VfEdge vfeKey) { for (var i = 0; i < loader.OutEdgeCount(vid); i++) { TE attr; vfeKey.IvtxTo = mpIvtxGraphIvtxVf[loader.PosFromId(loader.GetOutEdge(vid, i, out attr))]; if (!dctEdge.ContainsKey(vfeKey)) { _outEdges[i] = dctEdge[vfeKey] = new VfEdge(vfeKey.IvtxFrom, vfeKey.IvtxTo, attr); vfeKey = new VfEdge(vfeKey.IvtxFrom, vfeKey.IvtxTo, null); } else { _outEdges[i] = dctEdge[vfeKey]; } } }
private void MakeOutEdges(IGraphLoader loader, int nid, Dictionary <VfeNode, VfeNode> dctEdge, int[] mpInodGraphInodVf, ref VfeNode vfeKey) { object attr; for (int i = 0; i < loader.OutEdgeCount(nid); i++) { vfeKey._inodTo = mpInodGraphInodVf[loader.PosFromId(loader.GetOutEdge(nid, i, out attr))]; if (!dctEdge.ContainsKey(vfeKey)) { _arvfeEdgeOut[i] = dctEdge[vfeKey] = new VfeNode(vfeKey._inodFrom, vfeKey._inodTo, attr); vfeKey = new VfeNode(vfeKey._inodFrom, vfeKey._inodTo, null); } else { _arvfeEdgeOut[i] = dctEdge[vfeKey]; } } }