private function setLayout(AttributeAware $entity, array $layout) { $bag = new AttributeBagNamespaced($entity->getAttributeBag(), 'graphviz.'); $bag->setAttributes($layout); return $entity; }
protected function getLayoutEdge(Edge $edge) { $bag = new AttributeBagNamespaced($edge, 'graphviz.'); $layout = $bag->getAttributes(); // use flow/capacity/weight as edge label $label = NULL; $flow = $edge->getFlow(); $capacity = $edge->getCapacity(); // flow is set if ($flow !== NULL) { // NULL capacity = infinite capacity $label = $flow . '/' . ($capacity === NULL ? '∞' : $capacity); // capacity set, but not flow (assume zero flow) } elseif ($capacity !== NULL) { $label = '0/' . $capacity; } $weight = $edge->getWeight(); // weight is set if ($weight !== NULL) { if ($label === NULL) { $label = $weight; } else { $label .= '/' . $weight; } } if ($label !== NULL) { if (isset($layout['label'])) { $layout['label'] .= ' ' . $label; } else { $layout['label'] = $label; } } return $layout; }