llvm.org GIT mirror llvm / 6a98396
[PBQP] Update doxygen comment style to match the rest of the file. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218849 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 5 years ago
1 changed file(s) with 28 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
2828 typedef unsigned NodeId;
2929 typedef unsigned EdgeId;
3030
31 /// \brief Returns a value representing an invalid (non-existent) node.
31 /// @brief Returns a value representing an invalid (non-existent) node.
3232 static NodeId invalidNodeId() {
3333 return std::numeric_limits::max();
3434 }
3535
36 /// \brief Returns a value representing an invalid (non-existent) edge.
36 /// @brief Returns a value representing an invalid (non-existent) edge.
3737 static EdgeId invalidEdgeId() {
3838 return std::numeric_limits::max();
3939 }
329329 const NodeEntry ≠
330330 };
331331
332 /// \brief Construct an empty PBQP graph.
332 /// @brief Construct an empty PBQP graph.
333333 Graph() : Solver(nullptr) { }
334334
335 /// \brief Get a reference to the graph metadata.
335 /// @brief Get a reference to the graph metadata.
336336 GraphMetadata& getMetadata() { return Metadata; }
337337
338 /// \brief Get a const-reference to the graph metadata.
338 /// @brief Get a const-reference to the graph metadata.
339339 const GraphMetadata& getMetadata() const { return Metadata; }
340340
341 /// \brief Lock this graph to the given solver instance in preparation
341 /// @brief Lock this graph to the given solver instance in preparation
342342 /// for running the solver. This method will call solver.handleAddNode for
343343 /// each node in the graph, and handleAddEdge for each edge, to give the
344344 /// solver an opportunity to set up any requried metadata.
351351 Solver->handleAddEdge(EId);
352352 }
353353
354 /// \brief Release from solver instance.
354 /// @brief Release from solver instance.
355355 void unsetSolver() {
356356 assert(Solver && "Solver not set.");
357357 Solver = nullptr;
358358 }
359359
360 /// \brief Add a node with the given costs.
360 /// @brief Add a node with the given costs.
361361 /// @param Costs Cost vector for the new node.
362362 /// @return Node iterator for the added node.
363363 template
370370 return NId;
371371 }
372372
373 /// \brief Add an edge between the given nodes with the given costs.
373 /// @brief Add an edge between the given nodes with the given costs.
374374 /// @param N1Id First node.
375375 /// @param N2Id Second node.
376376 /// @return Edge iterator for the added edge.
387387 return EId;
388388 }
389389
390 /// \brief Returns true if the graph is empty.
390 /// @brief Returns true if the graph is empty.
391391 bool empty() const { return NodeIdSet(*this).empty(); }
392392
393393 NodeIdSet nodeIds() const { return NodeIdSet(*this); }
395395
396396 AdjEdgeIdSet adjEdgeIds(NodeId NId) { return AdjEdgeIdSet(getNode(NId)); }
397397
398 /// \brief Get the number of nodes in the graph.
398 /// @brief Get the number of nodes in the graph.
399399 /// @return Number of nodes in the graph.
400400 unsigned getNumNodes() const { return NodeIdSet(*this).size(); }
401401
402 /// \brief Get the number of edges in the graph.
402 /// @brief Get the number of edges in the graph.
403403 /// @return Number of edges in the graph.
404404 unsigned getNumEdges() const { return EdgeIdSet(*this).size(); }
405405
406 /// \brief Set a node's cost vector.
406 /// @brief Set a node's cost vector.
407407 /// @param NId Node to update.
408408 /// @param Costs New costs to set.
409409 template
414414 getNode(NId).Costs = AllocatedCosts;
415415 }
416416
417 /// \brief Get a node's cost vector (const version).
417 /// @brief Get a node's cost vector (const version).
418418 /// @param NId Node id.
419419 /// @return Node cost vector.
420420 const Vector& getNodeCosts(NodeId NId) const {
433433 return getNode(NId).getAdjEdgeIds().size();
434434 }
435435
436 /// \brief Set an edge's cost matrix.
436 /// @brief Set an edge's cost matrix.
437437 /// @param EId Edge id.
438438 /// @param Costs New cost matrix.
439439 template
444444 getEdge(EId).Costs = AllocatedCosts;
445445 }
446446
447 /// \brief Get an edge's cost matrix (const version).
447 /// @brief Get an edge's cost matrix (const version).
448448 /// @param EId Edge id.
449449 /// @return Edge cost matrix.
450450 const Matrix& getEdgeCosts(EdgeId EId) const { return *getEdge(EId).Costs; }
457457 return getEdge(NId).Metadata;
458458 }
459459
460 /// \brief Get the first node connected to this edge.
460 /// @brief Get the first node connected to this edge.
461461 /// @param EId Edge id.
462462 /// @return The first node connected to the given edge.
463463 NodeId getEdgeNode1Id(EdgeId EId) {
464464 return getEdge(EId).getN1Id();
465465 }
466466
467 /// \brief Get the second node connected to this edge.
467 /// @brief Get the second node connected to this edge.
468468 /// @param EId Edge id.
469469 /// @return The second node connected to the given edge.
470470 NodeId getEdgeNode2Id(EdgeId EId) {
471471 return getEdge(EId).getN2Id();
472472 }
473473
474 /// \brief Get the "other" node connected to this edge.
474 /// @brief Get the "other" node connected to this edge.
475475 /// @param EId Edge id.
476476 /// @param NId Node id for the "given" node.
477477 /// @return The iterator for the "other" node connected to this edge.
483483 return E.getN1Id();
484484 }
485485
486 /// \brief Get the edge connecting two nodes.
486 /// @brief Get the edge connecting two nodes.
487487 /// @param N1Id First node id.
488488 /// @param N2Id Second node id.
489489 /// @return An id for edge (N1Id, N2Id) if such an edge exists,
498498 return invalidEdgeId();
499499 }
500500
501 /// \brief Remove a node from the graph.
501 /// @brief Remove a node from the graph.
502502 /// @param NId Node id.
503503 void removeNode(NodeId NId) {
504504 if (Solver)
515515 FreeNodeIds.push_back(NId);
516516 }
517517
518 /// \brief Disconnect an edge from the given node.
518 /// @brief Disconnect an edge from the given node.
519519 ///
520520 /// Removes the given edge from the adjacency list of the given node.
521521 /// This operation leaves the edge in an 'asymmetric' state: It will no
548548 E.disconnectFrom(*this, NId);
549549 }
550550
551 /// \brief Convenience method to disconnect all neighbours from the given
551 /// @brief Convenience method to disconnect all neighbours from the given
552552 /// node.
553553 void disconnectAllNeighborsFromNode(NodeId NId) {
554554 for (auto AEId : adjEdgeIds(NId))
555555 disconnectEdge(AEId, getEdgeOtherNodeId(AEId, NId));
556556 }
557557
558 /// \brief Re-attach an edge to its nodes.
558 /// @brief Re-attach an edge to its nodes.
559559 ///
560560 /// Adds an edge that had been previously disconnected back into the
561561 /// adjacency set of the nodes that the edge connects.
566566 Solver->handleReconnectEdge(EId, NId);
567567 }
568568
569 /// \brief Remove an edge from the graph.
569 /// @brief Remove an edge from the graph.
570570 /// @param EId Edge id.
571571 void removeEdge(EdgeId EId) {
572572 if (Solver)
577577 Edges[EId].invalidate();
578578 }
579579
580 /// \brief Remove all nodes and edges from the graph.
580 /// @brief Remove all nodes and edges from the graph.
581581 void clear() {
582582 Nodes.clear();
583583 FreeNodeIds.clear();
585585 FreeEdgeIds.clear();
586586 }
587587
588 /// \brief Dump a graph to an output stream.
588 /// @brief Dump a graph to an output stream.
589589 template
590590 void dump(OStream &OS) {
591591 OS << nodeIds().size() << " " << edgeIds().size() << "\n";
620620 }
621621 }
622622
623 /// \brief Print a representation of this graph in DOT format.
623 /// @brief Print a representation of this graph in DOT format.
624624 /// @param OS Output stream to print on.
625625 template
626626 void printDot(OStream &OS) {