liveBook · Manning

Embedding

As explained in Advanced Algorithms and Data Structures

A vector is a mathematical quantity with magnitude and direction that can represent a displacement or directed geometric segment.

A printed circuit board needs more than a list of components and connections: components must be placed, and conductive tracks must be routed. A graph embedding gives an abstract graph a geometric layout by mapping vertices to points and edges to curves. The layout affects whether connections cross and how clearly the graph can be understood. section 15.0 section 15.5

In a 2-D embedding, distinct vertices occupy distinct positions, and an edge cannot pass through a vertex other than its endpoints. Edges may cross each other. If they do not, the embedding is planar; not every graph has one. An abstract graph can have many embeddings, with different numbers of crossings. section 15.1.2 section 15.2 section 15.5

For a straight-line drawing, build and assess an embedding incrementally:

  • Assign each vertex a point in the drawing area; connect the endpoints of each edge with a segment. section 16.1.1
  • Reject layouts with overlapping vertices or an edge passing through an unrelated vertex. For circular vertices, use center-to-center and vertex-to-segment distances. section 15.4.5 section 16.1.1
  • Count edge crossings to compare valid layouts. For two segments, compute where their supporting lines meet, then check whether the intersection lies within both segments; shared endpoints need separate treatment. section 15.4.1 section 16.1.1

One baseline generates several random valid layouts and keeps the one with the fewest crossings. The shown validation checks pairs of vertices and each edge against every unrelated vertex; crossing counts check pairs of edges. Those loops take O(V² + VE + E²) checks per candidate, before accounting for repeated attempts. Better layouts may require a richer objective: short edges, separated vertices, and readable use of space matter too. Gradient descent and simulated annealing are explored as ways to optimize such layouts. section 16.1.1 section 16.5 section 17.3.2

Crossings are not the whole picture

Two drawings of the same graph can convey its structure very differently. Random placement can obscure the symmetry of a complete bipartite graph; a deliberate symmetric placement makes it easier to see. The objective is therefore a useful drawing, not merely a valid one. section 17.3.2

Embedding also appears in image search in a different sense: a feature extractor translates each image into a feature vector, and search compares vectors rather than images directly. The feature extractor is treated as a black box. Here the representation supports similarity search, whereas a graph embedding specifies a geometric drawing of vertices and edges. section 10.1.1 section 10.3.1 section 15.5

How Advanced Algorithms and Data Structures covers it

How deep it goes
Develops graph-layout validation and crossing checks with pseudocode, while treating image feature extraction as a black box.
Examples
Uses circuit layouts, randomly sampled graph drawings, and catalog-image feature vectors as concrete cases.
What it assumes
Assumes familiarity with graphs and coordinates, then develops the vector operations used to check straight-line crossings.
What you can do after
Build it from scratch by assigning graph coordinates, validating the drawing, and comparing candidates by edge crossings.
How it connects
Connects graph embeddings to planarity, segment intersection, gradient descent, and simulated annealing; connects feature vectors to nearest-neighbor search.

Also explained in

Compare how 47 books explain embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.