/// <summary> /// Initializes a new instance of the <see cref="DAT"/> class. /// </summary> /// <param name="s">The s.</param> public DAT(Stream s) { Chunks.Clear(); ByteCover.Clear(); ByteCoverName.Clear(); AllVertices.Clear(); AllNormals.Clear(); AllTriangles.Clear(); vismapid.Clear(); br = new BinaryReader(s); while (s.Position < s.Length) { long offset = s.Position; CHUNK c = new CHUNK(s); uint d1 = (c.data.Length >= 4) ? BitConverter.ToUInt32(c.data, 0) : 0; uint d2 = (c.data.Length >= 8) ? BitConverter.ToUInt32(c.data, 4) : 0; ////Console.WriteLine("chunk: {0,8:x8} : {1}:{2,2:x2} {3,8:x8} bytes / {4,8:x8} {5,8:x8}", offset, c.FourCC, c.Type, c.Length, d1, d2); //File.WriteAllBytes(string.Format("{0,4:x4}{1}.enc", Chunks.Count, c.FourCC), c.data); CHUNK.Decrypt(c.data); string filename = string.Format("{0,4:x4}-{1}-{2,2:x2}.dec", Chunks.Count, c.FourCC, c.Type); #if WRITE_CHUNKS_TO_DISK if (!File.Exists(filename)) { File.WriteAllBytes(filename, c.data); } #endif c.Number = Chunks.Count; Chunks.Add(c); } s.Dispose(); br.Close(); br.Dispose(); }
public void AddVertex(TVertex vertex) { Contract.Requires(vertex != null); Contract.Requires(AllVertices.Contains(vertex) == false, "Vertex is already in the graph."); vertices.Add(vertex); RaiseChanged(); }
public void AddEdge(TVeticesEdge edge) { Contract.Requires(edge != null); Contract.Requires(AllVertices.Contains(edge.Source), "Edge's source does not belong to the graph."); Contract.Requires(AllVertices.Contains(edge.Destination), "Edge's source does not belong to the graph."); edges.Add(edge); RaiseChanged(); }
public void AddToVertices(Vertex vertex) { if (!AllVertices.Contains(vertex)) { AllVertices.Add(vertex); } else { var existingVertex = AllVertices.FirstOrDefault(v => v.Equals(vertex)); AllVertices.Add(vertex); } }
/// <summary> /// Add a weighted directed edge /// </summary> /// <param name="startId"></param> /// <param name="endId"></param> /// <param name="weight"></param> public void AddEdge(string startId, string endId, int weight) { if (!AllVertices.ContainsKey(startId)) { AllVertices[startId] = new GraphVertex(startId); } if (!AllVertices.ContainsKey(endId)) { AllVertices[endId] = new GraphVertex(endId); } AllVertices[startId].Neighbours.Add(AllVertices[endId]); EdgeWeights[startId + "#" + endId] = weight; }
public DirectedAcyclicGraph(IEnumerable <Vertex> vertices) { AllVertices = vertices.FlattenAndGetDistinct().ToList(); RootVertices = AllVertices.Where(v => !v.Dependencies.Any() || v.Dependencies.Count(d => AllVertices.Contains(d)) == 0) .ToList(); TerminalVertices = AllVertices.Where(v => !v.Dependents.Any()).ToList(); foreach (var terminalVertex in TerminalVertices) { terminalVertex.RemoveRedundantDependencies(); } }
public void AddEdge(int startVertexId, int endVertexId, int weight) { if (!AllVertices.ContainsKey(startVertexId)) { // if the graphvertex is not present then we need to add it AllVertices[startVertexId] = new GraphVertex(startVertexId); } if (!AllVertices.ContainsKey(endVertexId)) { // if the graphvertex is not present then we need to add it AllVertices[endVertexId] = new GraphVertex(endVertexId); } AllVertices[startVertexId].NeighbouringEdgesWithWeight.Add(new KeyValuePair <GraphVertex, int>(AllVertices[endVertexId], weight)); if (!IsDirected) { AllVertices[endVertexId].NeighbouringEdgesWithWeight.Add(new KeyValuePair <GraphVertex, int>(AllVertices[startVertexId], weight)); } }