1
Timings for random cubic graphs. We implemented the heuristics in Maple using a simple list of neighbors rep- resentation for G. Our software will become available in Maple’s GraphTheory package (see [4]) for Maple 17. We generated 10 random cubic graphs on n vertices and computed T (G, x, y ) using the MINDEG, VORDER-pull and VORDER-push heuristics. The first table is for a random vertex ordering. In the second table we relabeled the vertices using a SHARC ordering. Two timings, the median and average time, in CPU seconds, are reported. We used an Intel Core i7 desktop computer with 6 gigabytes of RAM. The data speaks for itself. MINDEG VORDER pull VORDER push n ave med ave med ave med 16 0.41 0.36 0.18 0.11 0.22 0.14 18 1.21 1.02 0.53 0.33 0.57 0.45 20 3.90 3.38 1.27 1.02 1.86 1.46 22 14.40 12.07 4.65 3.36 7.22 6.88 24 56.24 32.19 13.84 9.23 25.05 22.46 26 193.34 118.98 41.03 20.07 58.94 24.57 28 199.70 116.32 210.69 75.24 Timings (in seconds) for random cubic graphs with n vertices using random vertex order. MINDEG VORDER pull VORDER push n ave med ave med ave med 18 0.68 0.51 0.05 0.03 0.02 0.02 22 7.73 4.68 0.38 0.14 0.10 0.07 26 80.11 38.45 1.24 0.41 0.17 0.12 30 11.10 4.36 0.67 0.37 34 94.58 19.15 2.06 1.29 38 5.40 2.83 42 40.66 8.82 46 87.63 49.03 50 179.64 39.61 Timings (in seconds) for random cubic graphs with n vertices using SHARC vertex order. References [1 ] Gary Haggard, David Pearce, and Gordon Royle. Code for Computing Tutte Polynomials. homepages.ecs.vuw.ac.nz/˜djp/tutte [2 ] William Tutte. A contribution to the theory of chromatic polynomials. Can. J. Math. 6 (1954) 80-91. [3 ] Gary Haggard, David Pearce, and Gordon Royle. Computing Tutte Poly- nomials. Trans. on Math. Software 37:3 (2011) article 24. [4 ] Jeff Farr, Mahdad Khatarinejad, Sara Khodadad, and Michael Monagan. A Graph Theory Package for Maple. Proceedings of the 2005 Maple Con- ference, pp. 260–271, 2005. Two edge selection heuristics. 2 5 4 1 3 2 5 4 3 1 4 2 5 4 1 4 G G - e G/e VORDER-pull Consider the graph G shown in the figure above. The vertex order heuristic VORDER picks the edge e =(u, v ) where u is the first vertex in the G and v is the first vertex adjacent to u. In our example u =1, v =3, hence e = (1, 3) is chosen. Shown are the graphs G - e and G/e where when we contracted the edge e = (1, 3) we “pulled” vertex 3 down to vertex 1. So the next edge selected in G/e will be one of the edges (1,4). There is alternative choice here when constructing G/e. Instead of “pulling” vertex v =3 down to u =1, if instead we “push” vertex u =1 up to v =3 we get the contracted graph shown in the figure below. Observe that the two contracted graphs G/e in the figures are isomorphic. However, in the vertex order heuristic, the next edge selected in G/e is (2,4) which is different. 2 5 4 1 3 2 5 4 3 1 4 2 5 3 4 2 G G - e G/e VORDER-push The SHARC vertex order heuristic. The truncated icosahedron graph G and its planar dual G * . Their Tutte polynomials are related by T (G, x, y )= T (G * ,y,x). T (G * )= x 31 + 59 x 30 + 60 x 29 y + 1710 x 29 + ... + 160271797870414 y 2 + 11551226205884 y If you look at the vertex ordering in the truncated icosahedron graph above, you will see a cycle for vertices (1,2,3,4,5,6,1). The next three vertices (7,8,9) form a shortest path from the cycle back to the cycle, that visually looks like an arc. The next three vertices (10,11,12) form another shortest path from the set of vertices included so far back to itself. Repeating this gives an ordering on the vertices that we call a short arc ordering. It can be computed in linear time using a breadth-first-search in G. What difference does all this make? It turns out it makes a huge difference. We find that VORDER-push is much better than VORDER-pull and the SHARC ordering is consis- tently better than a simple breadth-first-search ordering and much better than depth-first- search ordering. Why? The paper suggests some reasons but we don’t really know. In [1] Garry Haggard and David Pearce computed the Tutte polyno- mial for the truncated icosahedron graph shown in the figure below right. It took their C++ code about one week to compute it on a grid of 150 computers. Using the edge selection and vertex order- ing heuristics presented here we are able to compute it in less than 2 minutes in Maple on a single core of an Intel Core i7 desktop. The new heuristics appear to work well for all sparse graphs. But first, what is the Tutte polynomial and why is it of interest? Definition (Tutte [2]). Let G be an undirected graph, possibly a multi-graph. Let e be any edge in G. Let G - e denote the graph obtained by deleting e and let G/e denote the graph obtained by contracting e, that is, first deleting e then joining e’s vertices. The Tutte polynomial, denoted T (G, x, y ), is defined by T (G)= 1 if G has no edges, x T (G/e) if e is a cut-edge in G, y T (G - e) if e is a loop in G T (G - e)+ T (G/e) otherwise. It follows that T (G) is a bivariate polynomial in x and y with inte- ger coefficients. The coefficients measure connectivity of G. The Tutte polynomial is of interest because the chromatic, flow and re- liability polynomials are special cases. But since computing those polynomials is NP-hard, computing the Tutte polynomial must also be NP-hard. The definition gives a recursive algorithm for computing T (G) known as the edge-deletion-contraction algorithm. The recursive calls in T (G - e)+ T (G/e) imply an exponential time complexity for com- puting it. If, however, we remember the Tutte polynomial for each recursive call in the computation tree, it may happen that we en- counter a graph that we have already seen which could reduce the cost, possibly to polynomial time, for some families of graphs. In [3] Haggard, Pearce and Royle use the graph isomorphism test from Brendan Makay’s nauty package to implement this idea. Roughly speaking, for random cubic graphs, this doubles the size of the graph they can handle in a given amount of time. Which edge in G should we pick? Which choice will more likely generate graphs that we have seen before in the computation tree? In [3] Haggard, Pearce and Royle propose two heuristics called MAXDEG and VORDER. By trying variations on their VORDER heuristic we have found one that works much better. Moreover, it is sufficient to test for identical graphs in the computation tree only – so no graph isomorphism test is needed. Michael Monagan. Department of Mathematics, Simon Fraser University, British Columbia. FPSAC 2012, Nagoya, Japan. A new edge selection heuristic for computing the Tutte polynomial.

Michael Monagan. Department of Mathematics, Simon Fraser ... · A Graph Theory Package for Maple. Proceedings of the 2005 Maple Con-ference, pp. 260–271, 2005. Two edge selection

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Michael Monagan. Department of Mathematics, Simon Fraser ... · A Graph Theory Package for Maple. Proceedings of the 2005 Maple Con-ference, pp. 260–271, 2005. Two edge selection

Timings for random cubic graphs.We implemented the heuristics in Maple using a simple list of neighbors rep-resentation for G. Our software will become available in Maple’sGraphTheory package (see [4]) for Maple 17.

We generated 10 random cubic graphs on n vertices and computed T (G, x, y)using the MINDEG, VORDER-pull and VORDER-push heuristics. The firsttable is for a random vertex ordering. In the second table we relabeled thevertices using a SHARC ordering. Two timings, the median and average time,in CPU seconds, are reported. We used an Intel Core i7 desktop computerwith 6 gigabytes of RAM. The data speaks for itself.

MINDEG VORDER pull VORDER pushn ave med ave med ave med16 0.41 0.36 0.18 0.11 0.22 0.1418 1.21 1.02 0.53 0.33 0.57 0.4520 3.90 3.38 1.27 1.02 1.86 1.4622 14.40 12.07 4.65 3.36 7.22 6.8824 56.24 32.19 13.84 9.23 25.05 22.4626 193.34 118.98 41.03 20.07 58.94 24.5728 199.70 116.32 210.69 75.24

Timings (in seconds) for random cubic graphs with n vertices using random vertex order.

MINDEG VORDER pull VORDER pushn ave med ave med ave med18 0.68 0.51 0.05 0.03 0.02 0.0222 7.73 4.68 0.38 0.14 0.10 0.0726 80.11 38.45 1.24 0.41 0.17 0.1230 11.10 4.36 0.67 0.3734 94.58 19.15 2.06 1.2938 5.40 2.8342 40.66 8.8246 87.63 49.0350 179.64 39.61

Timings (in seconds) for random cubic graphs with n vertices using SHARC vertex order.

References[1 ] Gary Haggard, David Pearce, and Gordon Royle. Code for Computing

Tutte Polynomials. homepages.ecs.vuw.ac.nz/˜djp/tutte

[2 ] William Tutte. A contribution to the theory of chromatic polynomials.Can. J. Math. 6 (1954) 80−91.

[3 ] Gary Haggard, David Pearce, and Gordon Royle. Computing Tutte Poly-nomials. Trans. on Math. Software 37:3 (2011) article 24.

[4 ] Jeff Farr, Mahdad Khatarinejad, Sara Khodadad, and Michael Monagan.A Graph Theory Package for Maple. Proceedings of the 2005 Maple Con-ference, pp. 260–271, 2005.

Two edge selection heuristics.

}2

}5

}4

��

���@

@@

@@

�������

ll

ll

ll

ll

}1

}3

DDDDDDD

}2

}5

}4}3

��

���@

@@

@@

�������

ll

ll

ll

ll

}1

}4

}2

}5

}4

��

���@

@@

@@

�������

ll

ll

ll

ll

}1

}4G G− e G / e

VORDER-pull

Consider the graph G shown in the figure above. The vertex order heuristic VORDERpicks the edge e = (u, v) where u is the first vertex in the G and v is the first vertexadjacent to u. In our example u = 1, v = 3, hence e = (1, 3) is chosen. Shown are thegraphs G−e and G / e where when we contracted the edge e = (1, 3) we “pulled” vertex3 down to vertex 1. So the next edge selected in G / e will be one of the edges (1,4).

There is alternative choice here when constructing G / e. Instead of “pulling” vertexv = 3 down to u = 1, if instead we “push” vertex u = 1 up to v = 3 we get thecontracted graph shown in the figure below. Observe that the two contracted graphsG / e in the figures are isomorphic. However, in the vertex order heuristic, the next edgeselected in G / e is (2,4) which is different.

}2

}5

}4

��

���@

@@

@@�������

ll

ll

ll

ll

}1

}3

DDDDDDD

}2

}5

}4}3

��

���@

@@

@@�������

ll

ll

ll

ll

}1

}4

}2

}5

}3 ����������@

@@

@@

}4

}2�������

G G− e G / e

VORDER-push

The SHARC vertex order heuristic.

The truncated icosahedron graph G and its planar dual G∗.Their Tutte polynomials are related by T (G, x, y) = T (G∗, y, x).

T (G∗) = x31 + 59 x30 + 60 x29y + 1710 x29 + . . . + 160271797870414 y2 + 11551226205884 y

If you look at the vertex ordering in the truncated icosahedron graph above, you willsee a cycle for vertices (1,2,3,4,5,6,1). The next three vertices (7,8,9) form a shortestpath from the cycle back to the cycle, that visually looks like an arc. The next threevertices (10,11,12) form another shortest path from the set of vertices included so farback to itself. Repeating this gives an ordering on the vertices that we call a short arcordering. It can be computed in linear time using a breadth-first-search in G.

What difference does all this make? It turns out it makes a huge difference. We find thatVORDER-push is much better than VORDER-pull and the SHARC ordering is consis-tently better than a simple breadth-first-search ordering and much better than depth-first-search ordering. Why? The paper suggests some reasons but we don’t really know.

In [1] Garry Haggard and David Pearce computed the Tutte polyno-mial for the truncated icosahedron graph shown in the figure belowright. It took their C++ code about one week to compute it on agrid of 150 computers. Using the edge selection and vertex order-ing heuristics presented here we are able to compute it in less than 2minutes in Maple on a single core of an Intel Core i7 desktop. Thenew heuristics appear to work well for all sparse graphs. But first,what is the Tutte polynomial and why is it of interest?

Definition (Tutte [2]). Let G be an undirected graph, possibly amulti-graph. Let e be any edge in G. Let G − e denote the graphobtained by deleting e and let G / e denote the graph obtained bycontracting e, that is, first deleting e then joining e’s vertices.

The Tutte polynomial, denoted T (G, x, y), is defined by

T (G) =

1 if G has no edges,x T (G / e) if e is a cut-edge in G,y T (G− e) if e is a loop in G

T (G− e) + T (G/e) otherwise.

It follows that T (G) is a bivariate polynomial in x and y with inte-ger coefficients. The coefficients measure connectivity of G. TheTutte polynomial is of interest because the chromatic, flow and re-liability polynomials are special cases. But since computing thosepolynomials is NP-hard, computing the Tutte polynomial must alsobe NP-hard.

The definition gives a recursive algorithm for computing T (G) knownas the edge-deletion-contraction algorithm. The recursive calls inT (G−e)+T (G / e) imply an exponential time complexity for com-puting it. If, however, we remember the Tutte polynomial for eachrecursive call in the computation tree, it may happen that we en-counter a graph that we have already seen which could reduce thecost, possibly to polynomial time, for some families of graphs. In[3] Haggard, Pearce and Royle use the graph isomorphism test fromBrendan Makay’s nauty package to implement this idea. Roughlyspeaking, for random cubic graphs, this doubles the size of thegraph they can handle in a given amount of time.

Which edge in G should we pick? Which choice will more likelygenerate graphs that we have seen before in the computation tree?In [3] Haggard, Pearce and Royle propose two heuristics calledMAXDEG and VORDER. By trying variations on their VORDERheuristic we have found one that works much better. Moreover, itis sufficient to test for identical graphs in the computation tree only– so no graph isomorphism test is needed.

Mathematical OperationsCommon manipulations (simplify,factor, expand,…) Right-click expression and select from menu

Solve equations Right-click equation Solve

Solve numerically (floating-point) Right-click equation Numerically Solve

Solve ODE Right-click DE expression Solve DE Interactively

Integrate, differentiate Right-click expression Integrate or Differentiate

Evaluate expression at a point Right-click expression Evaluate at a Point

Create a matrix or vector Matrix palette Choose Insert

Invert, transpose, solve matrixRight-click matrix Standard Operations selectInverse, Transpose, ...

Evaluate as floating-point Right-click expression Approximate

Various operations and tasks Use Task Templates: Tools Tasks Browse

Expressions vs. FunctionsOperations Expression x2+y2 Function (operator) g(x,y) = x2+y2

Definition !"#$"%&'"(")&'* +"#$",%-)."/0""%&'()&'*

Evaluate at x=1, y=2 1234,!-"5%$6-)$'7.*"produces 5 +,6-'.*"produces 5

3-D plot for x from 0 to 1, y from 0 to 1 849:;<,!-%$=>>6-)$=>>6.* 849:;<,+,%-).-%$=>>6-)$=>>6.*

Conversion to other form!'"#$"?@3884),!-%-).*

!',6-'.*

produces 5

+'"#$"+,%-6.*""

+'"("A*

produces x2+1+z

Units and Tolerances

Add units to value or expressionPlace cursor to right of quantity. Use Units (SI) or Units (FPS) palette or right-click Units Affix unit.

Add arbitrary unit from Units (SI) or Units (FPS) palette andenter desired unit

Simplify units in an expression Right-click expression Units Simplify

Convert units Right-click expression Units Convert

Enable automatic units simplification BC:D,E@C:F5G:3@<3H<7.*

Enable tolerance calculations BC:D,I941H3@J1F.*

Tolerance quantity in 2-D Math !"#$ %&% for 9 ± 1.1

Tolerance quantity in 1-D Math K"L(/"6>6* for 9 ± 1.1

Input and OutputInteractive data import assistant Tools Assistants Import Data

Import audio or image file Tools Assistants Import Data

Code generation (C, FORTRAN,Java, Visual Basic®, MATLAB®)

Right-click expression Language Conversions. See ?CodeGeneration for help and details.

Publish document in HTML, PDF,LaTeX, or Microsoft® Word-RTF

File Export As select HTML, PDF, LaTeX, or Rich Text Format

Select Interactive Tools and UtilitiesQuick introductory tour Help Take a Tour of Maple

Show available task templates Tools Tasks Browse

Plot BuilderRight-click expression Plots Plot Builder, or Tools Assistants Plot Builder

ODE Analyzer Tools Assistants ODE Analyzer

Data Analysis Assistant Tools Assistants Data Analysis

Unit Conversion utility Tools Assistants Units Calculator

Back-Solving Assistant Tools Assistants BackSolver

Apply numeric formatting Right-click expression Numeric Formatting

Maple Portal Help Manuals, Resources and more Maple Portal

Manuals Help Manuals, Resources, and more Manuals

Graphing Calculator Interface Installs as separate program. Launch from StartMaple Maple Calculator

Interactive education tutors for topics in Calculus, Precalculus, and Linear Algebra

Tools Tutors

P-06

48-1

3-E

Important Maple Syntax#$ Assignment 3#$'*"M#$;(%*"J#$3(M* produces 5 + x for J

$ Mathematical equation F9421,'N%"("3"$"6-%.* produces x =1-a—2

$ Boolean equality C!"3"$"="":D1@"O

Suppress display of output Terminate command with a colon, e.g. 6===P"#

[ ] List (ordered) A#$5J-"M-"37*"A567* produces c

{ } Set (unordered, no duplicates) Q3-"M-"3-"JR* produces {a,b,c }

Display help on topic S:98CJ

www.maplesoft.com | [email protected]

© Maplesoft, a division of Waterloo Maple Inc., 2009. Maplesoft and Maple are trademarks of Waterloo Maple Inc. All other trademarks are property of their respective owners.

t. 519.747.2373 | f. 519.747.5284800.267.6583 (US & Canada)

Plotting and AnimationPlot an existing expression - click expression Plots Plot Builder

Plot new expression Tools Assistants Plot Builder

Add new expression to existing plot Highlight and drag expression into plot

Add annotations to plots Click on plot, then on the toolbar

Animation and parameter plots for functions of several variables

Right-click expression Plots Plot Builderand select a plot type

!"#$%&'(&)*+,-&.%/%0%1,%&2"03& Windows® version

Michael Monagan. Department of Mathematics, Simon Fraser University, British Columbia. FPSAC 2012, Nagoya, Japan.

A new edge selection heuristic for computing the Tutte polynomial.

4

S I M O N F R A S E R U N I V E R S I T Y

SFU Logo