The XMPP network can be thought of as a bidirected graph with servers (S) operating in a mesh, clients (C) clustered about their local server, and streams represented by extraverted edges:
When a client wants to send data (eg. a message or presence information) across the network to another client, the message is always routed along the shorted possible path (from a client to its server, then to the remote client if they are on the same server or to the remote clients server and then to the client if the remote client is on a different server).