GraphTheory - Maple Programming Help

Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/GraphPower

GraphTheory

 GraphPower

 Calling Sequence GraphPower(G, k)

Parameters

 G - unweighted graph k - positive integer

Description

 • GraphPower returns the kth power graph of a given graph which may be directed or undirected. In the kth power graph, two vertices are connected if there exists a path of length at most k in the original graph.
 • The algorithm adds powers the adjacency matrix of G and removes any multiple edges.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $P≔\mathrm{PathGraph}\left(5\right)$
 ${P}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 5 vertices and 4 edge\left(s\right)}}$ (1)
 > $\mathrm{Edges}\left(P\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{3}{,}{4}\right\}{,}\left\{{4}{,}{5}\right\}\right\}$ (2)
 > $\mathrm{DrawGraph}\left(P,\mathrm{style}=\mathrm{circle}\right)$
 > $\mathrm{P2}≔\mathrm{GraphPower}\left(P,2\right)$
 ${\mathrm{P2}}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 5 vertices and 7 edge\left(s\right)}}$ (3)
 > $\mathrm{Edges}\left(\mathrm{P2}\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{2}{,}{4}\right\}{,}\left\{{3}{,}{4}\right\}{,}\left\{{3}{,}{5}\right\}{,}\left\{{4}{,}{5}\right\}\right\}$ (4)
 > $\mathrm{DrawGraph}\left(\mathrm{P2}\right)$
 > $\mathrm{P3}≔\mathrm{GraphPower}\left(P,3\right)$
 ${\mathrm{P3}}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 5 vertices and 9 edge\left(s\right)}}$ (5)
 > $\mathrm{Edges}\left(\mathrm{P3}\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{1}{,}{4}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{2}{,}{4}\right\}{,}\left\{{2}{,}{5}\right\}{,}\left\{{3}{,}{4}\right\}{,}\left\{{3}{,}{5}\right\}{,}\left\{{4}{,}{5}\right\}\right\}$ (6)
 > $\mathrm{DrawGraph}\left(\mathrm{P3}\right)$