edge_boundary#
- graph_tool.structure.edge_boundary(g, S, T=None)[git][source]#
Return the edge boundary of a set of vertices.
- Parameters:
- g
Graph Graph to be used.
- Siterable of
intorVertexPropertyMap Set of vertices, as a sequence of vertices or a Boolean vertex property map.
- Titerable of
intorVertexPropertyMap(optional, default:None) Second set of vertices. If not given, the complement of
Sis used.
- g
- Returns:
- edges
numpy.ndarray Array with one row
(s, t, i)for every edge of the boundary, wheresis inS,tinT, andiis the edge index.
- edges
See also
vertex_boundaryVertex counterpart
cut_sizeSize of the cut between two sets of vertices
Notes
The edge boundary contains the edges with one endpoint in \(S\) and the other in \(T\); for directed graphs, only the out-edges of the vertices in \(S\) are considered. The time is \(O(V + E)\).
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.edge_boundary(g, [0, 1, 2])[:4]) [[0 3 3] [1 3 4] [2 3 5] [0 4 6]]
The set and its boundary can be shown in a drawing of the network:
>>> es = gt.edge_boundary(g, [0, 1, 2]) >>> vcolor = g.new_vp("string", val="#cccccc") >>> for v in [0, 1, 2]: ... vcolor[v] = "#9bbedc" >>> inb = g.new_ep("bool") >>> inb.a[es[:, 2]] = True >>> ecolor = g.new_ep("string", vals=np.where(inb.a, "#e41a1c", ... "#999999")) >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor, ... edge_color=ecolor, output="edge_boundary-karate.pdf") <...>
Edge boundary (red) of the set of vertices 0, 1 and 2 (blue) of Zachary’s karate club network.#