COIN-OR::LEMON - Graph Library

Changeset 1646:2dd083dded66 in lemon-0.x for gui


Ignore:
Timestamp:
08/23/05 17:57:12 (14 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2159
Message:
  • handle the case when there is no id map in the edgeset section
  • do not use ListGraph?.id() to determine the id of a new node/edge
Location:
gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gui/graph_displayer_canvas-event.cc

    r1645 r1646  
    241241      mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));
    242242
    243       // update id map
    244       (*mapstorage.nodemap_storage["id"])[active_node] =
    245         mapstorage.graph.id(active_node);
    246 
    247243      // update all other maps
    248244      for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
     
    250246          mapstorage.nodemap_storage.end(); ++it)
    251247      {
    252         if ((it->first != "id") &&
    253             (it->first != "coordinates_x") &&
    254             (it->first != "coordiantes_y"))
     248        if ((it->first != "coordinates_x") &&
     249            (it->first != "coordinates_y"))
    255250        {
    256251          (*(it->second))[active_node] =
     
    258253        }
    259254      }
     255      // increment the id map's default value
     256      mapstorage.nodemap_default["id"] += 1.0;
    260257
    261258      nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
     
    357354                  target_node);
    358355
    359               // update id map
    360               (*mapstorage.edgemap_storage["id"])[active_edge] =
    361                 mapstorage.graph.id(active_edge);
    362  
    363               // update all other maps
     356              // update maps
    364357              for (std::map<std::string,
    365358                  Graph::EdgeMap<double>*>::const_iterator it =
     
    367360                  mapstorage.edgemap_storage.end(); ++it)
    368361              {
    369                 if (it->first != "id")
    370                 {
    371                   (*(it->second))[active_edge] =
    372                     mapstorage.edgemap_default[it->first];
    373                 }
     362                (*(it->second))[active_edge] =
     363                  mapstorage.edgemap_default[it->first];
    374364              }
     365              // increment the id map's default value
     366              mapstorage.edgemap_default["id"] += 1.0;
    375367
    376368              //calculating coordinates of new edge
  • gui/mapstorage.cc

    r1645 r1646  
    1212  nodemap_storage["id"] = new Graph::NodeMap<double>(graph);
    1313  edgemap_storage["id"] = new Graph::EdgeMap<double>(graph);
     14
     15  nodemap_default["id"] = 1.0;
     16  edgemap_default["id"] = 1.0;
    1417}
    1518
     
    126129  bool read_x = false;
    127130  bool read_y = false;
     131  bool read_edge_id = false;
    128132
    129133  try {
     
    183187  }
    184188
     189  if (!read_edge_id)
     190  {
     191    edgemap_storage["id"] = new Graph::EdgeMap<double>(graph);
     192    int i = 1;
     193    for (EdgeIt e(graph); e != INVALID; ++e)
     194    {
     195      (*edgemap_storage["id"])[e] = i++;
     196    }
     197  }
     198
    185199  if (!read_x || !read_y)
    186200  {
     
    211225      nodemap_default[it->first] = 0.0;
    212226    }
     227    else if (it->first == "id")
     228    {
     229      NodeIt n(graph);
     230      double max = (*nodemap_storage["id"])[n];
     231      for (; n != INVALID; ++n)
     232      {
     233        if ((*nodemap_storage["id"])[n] > max)
     234          max = (*nodemap_storage["id"])[n];
     235      }
     236      nodemap_default["id"] = max + 1.0;
     237    }
    213238  }
    214239  for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
     
    218243    {
    219244      edgemap_default[it->first] = 0.0;
     245    }
     246    else
     247    {
     248      EdgeIt e(graph);
     249      double max = (*edgemap_storage["id"])[e];
     250      for (; e != INVALID; ++e)
     251      {
     252        if ((*edgemap_storage["id"])[e] > max)
     253          max = (*edgemap_storage["id"])[e];
     254      }
     255      edgemap_default["id"] = max + 1.0;
    220256    }
    221257  }
     
    268304      nodemap_default.begin(); it != nodemap_default.end(); ++it)
    269305  {
    270     nodemap_default.erase(it);
     306    if (it->first != "id")
     307      nodemap_default.erase(it);
    271308  }
    272309  for (std::map<std::string, double>::iterator it =
    273310      edgemap_default.begin(); it != edgemap_default.end(); ++it)
    274311  {
    275     edgemap_default.erase(it);
     312    if (it->first != "id")
     313      edgemap_default.erase(it);
    276314  }
    277315  graph.clear();
Note: See TracChangeset for help on using the changeset viewer.