Skip to content

Instantly share code, notes, and snippets.

@NSMyself
NSMyself / graph.swift
Last active February 2, 2019 20:00
Graph (powered by adjacency lists) - IsTree
import Foundation
struct Edge<T> where T: Hashable {
var vertex: Vertex<T>
var edges: [Edge<T>] = []
}
struct Vertex<T> where T: Hashable {
let id: Int
let data: T