COIN-OR::LEMON - Graph Library

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


Ignore:
Timestamp:
08/23/05 17:57:12 (17 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.