2424 * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
2525 * @license http://www.opensource.org/licenses/mit-license.php MIT
2626 * @link http://phpdoc.org
27- *
27+ *
2828 * @method Graph setRankSep(string $rankSep)
2929 * @method Graph setCenter(string $center)
3030 * @method Graph setRank(string $rank)
@@ -41,6 +41,9 @@ class Graph
4141 /** @var string Type of this graph; may be digraph, graph or subgraph */
4242 protected $ type = 'digraph ' ;
4343
44+ /** @var bool If the graph is strict then multiple edges are not allowed between the same pairs of nodes */
45+ protected $ strict = false ;
46+
4447 /** @var \phpDocumentor\GraphViz\Attribute[] A list of attributes for this Graph */
4548 protected $ attributes = array ();
4649
@@ -53,6 +56,7 @@ class Graph
5356 /** @var \phpDocumentor\GraphViz\Edge[] A list of edges / arrows for this Graph */
5457 protected $ edges = array ();
5558
59+ /** @var string The path to execute dot from */
5660 protected $ path = '' ;
5761
5862 /**
@@ -148,6 +152,28 @@ public function getType()
148152 return $ this ->type ;
149153 }
150154
155+ /**
156+ * Set if the Graph should be strict. If the graph is strict then
157+ * multiple edges are not allowed between the same pairs of nodes
158+ *
159+ * @param bool $isStrict
160+ *
161+ * @return \phpDocumentor\GraphViz\Graph
162+ */
163+ public function setStrict ($ isStrict )
164+ {
165+ $ this ->strict = $ isStrict ;
166+ return $ this ;
167+ }
168+
169+ /**
170+ * @return bool
171+ */
172+ public function isStrict ()
173+ {
174+ return $ this ->strict ;
175+ }
176+
151177 /**
152178 * Magic method to provide a getter/setter to add attributes on the Graph.
153179 *
@@ -375,8 +401,10 @@ public function __toString()
375401 }
376402 $ attributes = implode (PHP_EOL , $ attributes );
377403
404+ $ strict = ($ this ->isStrict () ? 'strict ' : '' );
405+
378406 return <<<DOT
379- {$ this ->getType ()} " {$ this ->getName ()}" {
407+ {$ strict }{ $ this ->getType ()} " {$ this ->getName ()}" {
380408$ attributes
381409}
382410DOT ;
0 commit comments