Tx · LaTeX & TikZ

How to Draw an Edge From a TikZ Node With No Target Node

Published By the 9to5Science editorial team

At a glance

  1. 1. Choose a direction

    Decide where the dangling edge should point and how long it should be.

  2. 2. Start at the node

    Use the node or one of its anchors, such as (a.east), as the path start.

  3. 3. Give a coordinate endpoint

    Draw to a relative coordinate with -- ++(dx,dy), and add an arrow tip if needed.

If you want an edge to leave a node and point into empty space, use a coordinate as its endpoint. TikZ does not require every edge to connect two named nodes; it requires the path to have a destination, and that destination can be an ordinary coordinate.

For a short arrow pointing right from node a, write \draw[->] (a.east) -- ++(1,0);. The relative coordinate makes the arrow endpoint one unit to the right of the node’s east anchor.

Use a relative coordinate as the endpoint

A TikZ path such as -- (b) ends at a named node or coordinate. Replace the named destination with a coordinate relative to the start:

\draw[->] (a.east) -- ++(1,0);

Here, (a.east) is the starting point and ++(1,0) is the endpoint: one TikZ unit to the right and zero units vertically. Change the numbers to set the direction and length. For example, ++(0,1) points up, while ++(-0.8,0.4) points up and left.

Use a node anchor such as .east, .west, .north, or .south when the edge should start at the node’s boundary. Starting at (a) uses the node’s center, so the line can appear to run underneath the node.

Complete example

This example draws two named nodes and a separate arrow stub that leaves the first node. It needs only the tikz package; the stub does not require the graph-drawing library.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node[draw, circle] (a) at (0,0) {$a$};
  \node[draw, circle] (b) at (2,0) {$b$};

  \draw (a) -- (b);
  \draw[->, red, thick] (a.east) -- ++(1,0);
\end{tikzpicture}
\end{document}

The first \draw connects the two nodes. The second draws an independent red arrow from the east edge of a into empty space. There is no target node at the arrow tip. If you already have nodes from a \graph declaration, you can draw a separate path from a named node in the same way, provided you know the node’s name.

Choose between + and ++

Both +(dx,dy) and ++(dx,dy) specify a coordinate relative to the current point. In a simple path that ends at that coordinate, either works:

\draw[->] (a.east) -- +(1,0);

The difference matters when the path continues. ++ updates the current point to the new coordinate, so the next segment starts there. + does not update it. For a single dangling segment, ++ is a clear, common choice.

You can also use a direction-and-length path operation, for example \draw[->] (a.east) -- ++(1,0);. If you want a curved stub, use a coordinate endpoint with a curved path:

\draw[->] (a.east) to[out=0, in=180] ++(1.2,0.5);

The out and in angles control the curve’s departure and arrival directions; the relative coordinate still supplies an endpoint, not a node.

Common mistakes

  • Writing an edge with no destination at all: TikZ needs a point where the path ends. Use a coordinate even when you do not want a visible target node.
  • Starting at the node center: (a) starts at the node’s center. Use an anchor such as (a.east) if the edge should emerge from the outline.
  • Using the wrong direction: Coordinates use (x,y). A positive first value moves right; a positive second value moves up.
  • Expecting a graph edge to create a dangling endpoint automatically: Graph notation describes connections between vertices. For a free-ended stub, draw an ordinary TikZ path from the vertex to a coordinate.
  • Forgetting the arrow option: A line segment alone has no arrowhead. Add -> to the draw options, as in \draw[->] ....

If the arrowhead overlaps the node outline, adjust its starting anchor or shorten the segment. For example, start at (a.east) rather than (a) and choose a relative endpoint far enough from the node to make the arrow visible.

References

  1. PGF/TikZ Manual: Paths

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.