<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>adjacencyMatrix -- returns the adjacency Matrix of a graph</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_all__Even__Holes.html">next</a> | <a href="index.html">previous</a> | <a href="_all__Even__Holes.html">forward</a> | <a href="index.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>adjacencyMatrix -- returns the adjacency Matrix of a graph</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>M = adjacencyMatrix G</tt></div> </dd></dl> </div> </li> <li><div class="single">Inputs:<ul><li><span><tt>G</tt>, <span>a <a href="___Graph.html">graph</a></span></span></li> </ul> </div> </li> <li><div class="single">Outputs:<ul><li><span><tt>M</tt>, <span>a <a href="../../Macaulay2Doc/html/___Matrix.html">matrix</a></span>, the adjacency matrix of the graph</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><div>This function returns the adjacency matrix of the given graph <tt>G</tt>. The (i,j)<sup>th</sup> position of the matrix is 1 if there is an edge between the i<sup>th</sup> vertex and j<sup>th</sup> vertex, and 0 otherwise. The rows and columns are indexed by the variables of the ring and use the ordering of the variables for determining the order of the rows and columns.</div> <table class="examples"><tr><td><pre>i1 : S = QQ[a..f];</pre> </td></tr> <tr><td><pre>i2 : G = graph {a*b,a*c,b*c,c*d,d*e,e*f,f*a,a*d} o2 = Graph{edges => {{a, b}, {a, c}, {b, c}, {a, d}, {c, d}, {d, e}, {a, f}, {e, f}}} ring => S vertices => {a, b, c, d, e, f} o2 : Graph</pre> </td></tr> <tr><td><pre>i3 : t = adjacencyMatrix G o3 = | 0 1 1 1 0 1 | | 1 0 1 0 0 0 | | 1 1 0 1 0 0 | | 1 0 1 0 1 0 | | 0 0 0 1 0 1 | | 1 0 0 0 1 0 | 6 6 o3 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i4 : T = QQ[f,e,d,c,b,a];</pre> </td></tr> <tr><td><pre>i5 : G = graph {a*b,a*c,b*c,c*d,d*e,e*f,f*a,a*d} o5 = Graph{edges => {{f, e}, {e, d}, {d, c}, {c, b}, {f, a}, {d, a}, {c, a}, {b, a}}} ring => T vertices => {f, e, d, c, b, a} o5 : Graph</pre> </td></tr> <tr><td><pre>i6 : t = adjacencyMatrix G -- although the same graph, matrix is different since variables have different ordering o6 = | 0 1 0 0 0 1 | | 1 0 1 0 0 0 | | 0 1 0 1 0 1 | | 0 0 1 0 1 1 | | 0 0 0 1 0 1 | | 1 0 1 1 1 0 | 6 6 o6 : Matrix ZZ <--- ZZ</pre> </td></tr> </table> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_incidence__Matrix.html" title="returns the incidence matrix of a hypergraph">incidenceMatrix</a> -- returns the incidence matrix of a hypergraph</span></li> <li><span><a href="_vertices.html" title="gets the vertices of a (hyper)graph">vertices</a> -- gets the vertices of a (hyper)graph</span></li> </ul> </div> <div class="waystouse"><h2>Ways to use <tt>adjacencyMatrix</tt> :</h2> <ul><li>adjacencyMatrix(Graph)</li> </ul> </div> </div> </body> </html>