using System.Collections.Generic; using System.Linq; using UnityEngine; namespace Code.Lab6 { [System.Serializable] public class Vertex : MonoBehaviour { public int id = -1; public List neighbours; [HideInInspector] public Vertex prev; private void Awake() { neighbours ??= new List(); } private void OnDrawGizmos() { Gizmos.color = Color.cyan; Gizmos.DrawSphere(transform.position, 0.2f); } private void OnDrawGizmosSelected() { if (neighbours == null) return; Gizmos.color = Color.yellow; foreach (var edge in neighbours.Where(edge => edge?.Vertex != null)) { Gizmos.DrawLine(transform.position, edge.Vertex.transform.position); } } } }