Say I have a directed edge from node $u$ to node $v$. By what names can I refer to $u$ and $v$ that describe their “role” in the edge. Ideally, I’d like the name to be short (because it’s for writing code), but also adhering to some standard.
Candidates I’ve thought of but rejected:
- from node and to node. Clearest, but too long if I need to use them in other variable/function names.
- source and sink. Shorter, but only a standard for network-flow folk. Might be too obscure for some.
- from and to. Nice, but clashes with reserved words in Python.
- v₀ and v₁ (for
vertex[0]andvertex[1]). Very short, but obscure to all.
Note that this question is not what I’m after as it asks for ways to express this using mathematical notation instead of words.
I will start with a bit of a frame challenge: it does not matter what you call the two vertices of an edge in a digraph. Even less important is how you label these nodes in your code. You can adopt whatever convention you like. Some conventions will be easier for others to read and understand than others, but the choice is really up to you. In this sense, there is no one "right" answer (though there are infinitely many "wrong" answers, as there are a lot of things you could do to make your code or your writing less readable).
That being said, if you are trying to produce something readable for others, it would probably be reasonable to adopt a standard which is descriptive. Some possibilities include the following:
Let $u$ and $v$ be two nodes in a digraph and let $e = (u,v)$ denote the directed edge which goes from $u$ to $y$. Then
Wikipedia suggests that $u$ is the tail and $v$ is the head of $e$;
this set of notes from Carnegie Mellon uses the terms origin and destination of $e$ for the nodes $u$ and $v$, repectively;
as suggested by JMoravitz in a now-deleted comment,
from_nodeandto_nodemight be reasonable variable or function names in a programming context, e.g. the nodeuis the output offrom_node(e), whilevis the output ofto_node(e);it seems natural to me to call $u$ the start of $e$ and to call $v$ the end of $e$, though some quick Googling indicates that this terminology is likely rather rare; on the other hand, I seem to recall writing $s(E)$ and $e(E)$ to denote the start and end of an edge $E$ in a graph theory course I took maybe 15 years ago, so perhaps there is precedent;
Mathworks calls $u$ the source of $e$, and $v$ the target of $e$ (note that this nomenclature is also common in category theory: a morphism between objects has a source and target).