Changeset 2076:10681ee9d8ae in lemon0.x for lemon/smart_graph.h
 Timestamp:
 05/12/06 11:51:45 (14 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2739
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/smart_graph.h
r2031 r2076 120 120 static int id(Edge e) { return e.n; } 121 121 122 /// \brief Returns the node from its \c id. 123 /// 124 /// Returns the node from its \c id. If there is not node 125 /// with the given id the effect of the function is undefinied. 122 126 static Node nodeFromId(int id) { return Node(id);} 123 127 128 /// \brief Returns the edge from its \c id. 129 /// 130 /// Returns the edge from its \c id. If there is not edge 131 /// with the given id the effect of the function is undefinied. 124 132 static Edge edgeFromId(int id) { return Edge(id);} 125 133 … … 351 359 /**************** Undirected List Graph ****************/ 352 360 353 typedef UGraphExtender<U GraphBaseExtender<SmartGraphBase> >361 typedef UGraphExtender<UndirGraphExtender<SmartGraphBase> > 354 362 ExtendedSmartUGraphBase; 355 363 … … 389 397 }; 390 398 391 struct EdgeT {399 struct UEdgeT { 392 400 int aNode, next_out; 393 401 int bNode, next_in; … … 397 405 std::vector<NodeT> bNodes; 398 406 399 std::vector< EdgeT> edges;407 std::vector<UEdgeT> edges; 400 408 401 409 public: … … 415 423 }; 416 424 417 class Edge {425 class UEdge { 418 426 friend class SmartBpUGraphBase; 419 427 protected: 420 428 int id; 421 429 422 Edge(int _id) { id = _id;}430 UEdge(int _id) { id = _id;} 423 431 public: 424 Edge() {}425 Edge (Invalid) { id = 1; }426 bool operator==(const Edge i) const {return id==i.id;}427 bool operator!=(const Edge i) const {return id!=i.id;}428 bool operator<(const Edge i) const {return id<i.id;}432 UEdge() {} 433 UEdge (Invalid) { id = 1; } 434 bool operator==(const UEdge i) const {return id==i.id;} 435 bool operator!=(const UEdge i) const {return id!=i.id;} 436 bool operator<(const UEdge i) const {return id<i.id;} 429 437 }; 430 438 … … 459 467 } 460 468 461 void first( Edge& edge) const {469 void first(UEdge& edge) const { 462 470 edge.id = edges.size()  1; 463 471 } 464 void next( Edge& edge) const {472 void next(UEdge& edge) const { 465 473 edge.id; 466 474 } 467 475 468 void first Out(Edge& edge, const Node& node) const {476 void firstFromANode(UEdge& edge, const Node& node) const { 469 477 LEMON_ASSERT((node.id & 1) == 0, NodeSetError()); 470 478 edge.id = aNodes[node.id >> 1].first; 471 479 } 472 void next Out(Edge& edge) const {480 void nextFromANode(UEdge& edge) const { 473 481 edge.id = edges[edge.id].next_out; 474 482 } 475 483 476 void first In(Edge& edge, const Node& node) const {484 void firstFromBNode(UEdge& edge, const Node& node) const { 477 485 LEMON_ASSERT((node.id & 1) == 1, NodeSetError()); 478 486 edge.id = bNodes[node.id >> 1].first; 479 487 } 480 void next In(Edge& edge) const {488 void nextFromBNode(UEdge& edge) const { 481 489 edge.id = edges[edge.id].next_in; 482 490 } … … 493 501 } 494 502 495 static int id(const Edge& edge) {503 static int id(const UEdge& edge) { 496 504 return edge.id; 497 505 } 498 static Edge edgeFromId(int id) {499 return Edge(id);500 } 501 int max EdgeId() const {506 static UEdge uEdgeFromId(int id) { 507 return UEdge(id); 508 } 509 int maxUEdgeId() const { 502 510 return edges.size(); 503 511 } … … 523 531 } 524 532 525 Node aNode(const Edge& edge) const {533 Node aNode(const UEdge& edge) const { 526 534 return Node(edges[edge.id].aNode); 527 535 } 528 Node bNode(const Edge& edge) const {536 Node bNode(const UEdge& edge) const { 529 537 return Node(edges[edge.id].bNode); 530 538 } … … 552 560 } 553 561 554 Edge addEdge(const Node& source, const Node& target) {562 UEdge addEdge(const Node& source, const Node& target) { 555 563 LEMON_ASSERT(((source.id ^ target.id) & 1) == 1, NodeSetError()); 556 EdgeT edgeT;564 UEdgeT edgeT; 557 565 if ((source.id & 1) == 0) { 558 566 edgeT.aNode = source.id; … … 567 575 bNodes[edgeT.bNode >> 1].first = edges.size(); 568 576 edges.push_back(edgeT); 569 return Edge(edges.size()  1);577 return UEdge(edges.size()  1); 570 578 } 571 579 … … 582 590 583 591 typedef True EdgeNumTag; 584 int edgeNum() const { return edges.size(); }592 int uEdgeNum() const { return edges.size(); } 585 593 586 594 }; 587 595 588 596 589 typedef BpUGraphExtender< BpUGraphBaseExtender< 590 SmartBpUGraphBase> > ExtendedSmartBpUGraphBase; 597 typedef BpUGraphExtender<SmartBpUGraphBase> ExtendedSmartBpUGraphBase; 591 598 592 599 /// \ingroup graphs
Note: See TracChangeset
for help on using the changeset viewer.