Files
siliconsGitHubVM_USER <VM_USER>silicons
8ca04ad274 persistence update + spraycans + graffiti + persistent debris + glass shards (#4301)
Co-authored-by: VM_USER <VM_USER>
Co-authored-by: silicons <no@you.cat>
2024-03-04 23:06:10 +01:00

39 lines
1.1 KiB
Plaintext

//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station developers. *//
/**
* Warning. This file is very strongly coupled with Citade Station's rust-g repository,
* notably geometry.rs. Do not mess with things in here unless you know what you are doing.
*/
/**
* directed graph
*
* vertices can be arbitrary datums
*/
/datum/digraph
/// vertices, associated to connected vertices
var/list/vertices = list()
/datum/digraph/proc/add_vertex(datum/D)
// strong assertion due to risk of corruption
ASSERT(isnull(vertices[D]))
vertices[D] = list()
/datum/digraph/proc/remove_vertex(datum/D)
// strong assertion due to risk of corruption
ASSERT(!isnull(vertices[D]))
vertices -= D
/datum/digraph/proc/is_connected(datum/A, datum/B)
// no assertion - this will runtime if it's not there
return vertices[A][B]
/datum/digraph/proc/connect(datum/A, datum/B)
// no assertion - this will runtime if it's not there
vertices[A][B] = TRUE
/datum/digraph/proc/disconnect(datum/A, datum/B)
// no assertion - this will runtime if it's not there
vertices[A] -= B