static inline void writeEdge( std::ostream &out, int depth, const GraphAttributes *GA, edge e) { if(GA) { GraphIO::indent(out, depth) << "<edge id=\"" << e->index() << "\""; if(GA->attributes() & GraphAttributes::edgeLabel) { out << " label=\"" << GA->label(e) << "\""; } out << ">\n"; writeAttributes(out, depth + 1, *GA, e); GraphIO::indent(out, depth) << "</edge>\n"; } else { GraphIO::indent(out, depth) << "<edge " << "id=\"" << e->index() << "\" " << "source=\"" << e->source() << "\" " << "target=\"" << e->target() << "\" " << "/>\n"; } }
forall_edges(e,G) { const BendString &bs1 = bend(e->adjSource()); const BendString &bs2 = bend(e->adjTarget()); if (bs1.size() != bs2.size()) { error.sprintf( "Size of corresponding bend strings at edge %d differ!", e->index()); return false; } size_t i = 0, j = bs2.size()-1; while(i < bs1.size()) { if (bs1[i] != flip(bs2[j])) { error.sprintf( "Corresponding bend strings at edge %d not consistent!", e->index()); return false; } ++i; --j; } }
bool MultilevelGraph::deleteEdge(NodeMerge * NM, edge theEdge) { int index = theEdge->index(); NM->m_deletedEdges.push_back(index); NM->m_doubleWeight[index] = m_weight[theEdge]; NM->m_source[index] = theEdge->source()->index(); NM->m_target[index] = theEdge->target()->index(); m_G->delEdge(theEdge); m_reverseEdgeIndex[index] = nullptr; return true; }
void MultilevelGraph::copyEdgeTo(edge e, MultilevelGraph &MLG, std::map<node, node> &tempNodeAssociations, bool associate, int index) { node source = e->source(); node target = e->target(); edge e_new; if (index == -1) { e_new = MLG.m_G->newEdge(tempNodeAssociations[source], tempNodeAssociations[target]); } else { e_new = MLG.m_G->newEdge(tempNodeAssociations[source], tempNodeAssociations[target], index); } if(associate) { MLG.m_edgeAssociations[e_new] = e->index(); } MLG.m_weight[e_new] = m_weight[e]; }
bool MultilevelGraph::changeEdge(NodeMerge * NM, edge theEdge, double newWeight, node newSource, node newTarget) { int index = theEdge->index(); std::vector<int>::iterator pos = find(NM->m_changedEdges.begin(), NM->m_changedEdges.end(), index); if (pos == NM->m_changedEdges.end()) { NM->m_changedEdges.push_back(index); NM->m_doubleWeight[index] = m_weight[theEdge]; NM->m_source[index] = theEdge->source()->index(); NM->m_target[index] = theEdge->target()->index(); } m_G->delEdge(theEdge); edge newEdge = m_G->newEdge(newSource, newTarget, index); m_reverseEdgeIndex[index] = newEdge; m_weight[newEdge] = newWeight; return true; }
forall_edges(e, G) { edge e_new = m_G->newEdge(tempAssociations[e->source()], tempAssociations[e->target()]); m_edgeAssociations[e_new] = e->index(); }