Skip to content

Commit

Permalink
Merge pull request #1240 from trws/bidirectional
Browse files Browse the repository at this point in the history
graph: use builtin bidirectional graph
  • Loading branch information
mergify[bot] committed Jul 11, 2024
2 parents 2ad04a2 + 742812d commit fc4fcde
Show file tree
Hide file tree
Showing 12 changed files with 3,829 additions and 38,661 deletions.
5 changes: 0 additions & 5 deletions resource/readers/resource_reader_grug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@ void dfs_emitter_t::emit_edges (gge_t ge, const gg_t &recipe,
g[e].idata.member_of[recipe[ge].e_subsystem]
= recipe[ge].relation;
g[e].name[recipe[ge].e_subsystem] = recipe[ge].relation;
if ( (rc = raw_edge (tgt_v, src_v, e)) < 0)
return;
g[e].idata.member_of[recipe[ge].e_subsystem]
= recipe[ge].rrelation;
g[e].name[recipe[ge].e_subsystem] = recipe[ge].rrelation;
}

vtx_t dfs_emitter_t::emit_vertex (ggv_t u, gge_t e, const gg_t &recipe,
Expand Down
12 changes: 0 additions & 12 deletions resource/readers/resource_reader_hwloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ int resource_reader_hwloc_t::walk_hwloc (resource_graph_t &g,
name, properties, size, rank);
valid_ancestor = v;
std::string relation = "contains";
std::string rev_relation = "in";
edg_t e;
bool inserted; // set to false when we try and insert a parallel edge

Expand All @@ -378,17 +377,6 @@ int resource_reader_hwloc_t::walk_hwloc (resource_graph_t &g,
if (add_metadata (m, e, parent, v, g) < 0)
return -1;

tie (e, inserted) = add_edge (v, parent, g);
if (!inserted) {
errno = ENOMEM;
m_err_msg += "error inserting a new edge: "
+ g[v].name + " -> " + g[parent].name + "; ";
return -1;
}
g[e].idata.member_of[subsys] = rev_relation;
g[e].name[subsys] = rev_relation;
if (add_metadata (m, e, v, parent, g) < 0)
return -1;
}

hwloc_obj_t curr_child = NULL;
Expand Down
35 changes: 16 additions & 19 deletions resource/readers/resource_reader_jgf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,10 +1068,12 @@ int resource_reader_jgf_t::unpack_edges (resource_graph_t &g,
goto done;
}
json_object_foreach (name, key, value) {
g[e].name[std::string (key)]
= std::string (json_string_value (value));
g[e].idata.member_of[std::string (key)]
= std::string (json_string_value (value));
auto skey = std::string (key);
auto sval = std::string (json_string_value (value), json_string_length (value));
if (sval == std::string ("in"))
continue;
g[e].name[skey] = sval;
g[e].idata.member_of[skey] = sval;
}
// add this edge to by_outedges metadata
auto iter = m.by_outedges.find (vmap[source].v);
Expand Down Expand Up @@ -1224,27 +1226,22 @@ int resource_reader_jgf_t::get_subgraph_vertices (resource_graph_t &g,
int resource_reader_jgf_t::get_parent_vtx (resource_graph_t &g,
vtx_t vtx,
vtx_t &parent_vtx)

{
vtx_t next_vtx;
boost::graph_traits<resource_graph_t>::out_edge_iterator ei, ei_end;
boost::tie (ei, ei_end) = boost::out_edges (vtx, g);
boost::graph_traits<resource_graph_t>::in_edge_iterator ei, ei_end;
boost::tie (ei, ei_end) = boost::in_edges (vtx, g);
int rc = -1;

for (; ei != ei_end; ++ei) {
next_vtx = boost::target (*ei, g);
for (const auto &paths_it : g[vtx].paths) {
// check that the parent's name exists in the child's path before the child's name
if (paths_it.second.find (g[next_vtx].name) != std::string::npos &&
paths_it.second.find (g[vtx].name) > paths_it.second.find (g[next_vtx].name)) {
parent_vtx = next_vtx;
rc = 0;
break;
}
}
}
next_vtx = boost::source (*ei, g);
if (g[*ei].name.contains ("containment")) {
parent_vtx = next_vtx;
rc = 0;
break;
}
}

return rc;
return rc;
}


Expand Down
10 changes: 0 additions & 10 deletions resource/readers/resource_reader_rv1exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,6 @@ int resource_reader_rv1exec_t::add_edges (resource_graph_t &g,
if (add_metadata (g, m, e, src, dst) < 0)
goto error;

tie (e, inserted) = add_edge (dst, src, g);
if (!inserted) {
errno = ENOMEM;
goto error;
}
g[e].idata.member_of[subsys] = rev_relation;
g[e].name[subsys] = rev_relation;
if (add_metadata (g, m, e, dst, src) < 0)
goto error;

return 0;

error:
Expand Down
4 changes: 1 addition & 3 deletions resource/schema/resource_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
#define RESOURCE_GRAPH_HPP

#include "resource/schema/resource_data.hpp"
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphml.hpp>
#include <boost/graph/graphviz.hpp>

#include <utility>
#include <memory>

namespace Flux {
namespace resource_model {
Expand All @@ -31,7 +29,7 @@ using rname_t = std::string resource_relation_t::*;
using rinfra_t = relation_infra_t resource_relation_t::*;
using resource_graph_t = boost::adjacency_list<boost::vecS,
boost::vecS,
boost::directedS,
boost::bidirectionalS,
resource_pool_t,
resource_relation_t,
std::string>;
Expand Down
Loading

0 comments on commit fc4fcde

Please sign in to comment.