/// <summary> /// Add a new vertex to the graph and returns it. /// /// Complexity: 1 insertion. /// </summary> /// <returns>Create vertex</returns> public virtual IVertex AddVertex() { IVertex v = VertexProvider.ProvideVertex(); VertexOutEdges.Add(v, new EdgeCollection()); return(v); }
/// <summary> /// Add a new vertex to the graph and returns it. /// /// Complexity: 1 insertion. /// </summary> /// <returns>Create vertex</returns> public virtual void AddVertex(IVertex v) { if (v == null) { throw new ArgumentNullException("vertex"); } if (VertexOutEdges.Contains(v)) { throw new ArgumentException("vertex already in graph"); } VertexProvider.UpdateVertex(v); VertexOutEdges.Add(v, new EdgeCollection()); }
void Start() { World initialWorld = new World(); for (int i = 0; i < locationCount; i++) { float angle = Random.Range(0, 2 * Mathf.PI); float r = Random.Range(minWorldRadius, maxWorldRadius); initialWorld.Locations.Add(new Vector3(r * Mathf.Sin(angle), r * Mathf.Cos(angle), r * Mathf.Cos(angle))); } VertexProvider vProvider = new VertexProvider(targetObj.GetComponent <MeshFilter>().mesh, targetObj.transform); initialWorld.Locations = vProvider.GetVertexSamples(1000); sa = new SimulatedAnnealing(initialTemp, coolingRate, initialWorld); sa.Findsolution(); // Prepare camera for render Camera.main.clearFlags = CameraClearFlags.SolidColor; Camera.main.backgroundColor = Color.white; StartCoroutine(DontClearCamera()); }