The following code is for the Graph class:
- Create the backbone with the member values:
using UnityEngine; using System.Collections; using System.Collections.Generic; public abstract class Graph : MonoBehaviour { public GameObject vertexPrefab; protected List<Vertex> vertices; protected List<List<Vertex>> neighbours; protected List<List<float>> costs; // next steps }
- Define the Start function:
public virtual void Start() { Load(); }
- Define the Load function, mentioned previously:
public virtual void Load() { }
- Implement the function for getting the graph's size:
public virtual int GetSize() { if (ReferenceEquals(vertices, null)) return 0; return vertices.Count; }
- Define the function for finding the nearest vertex ...