Classes | Public Types | Public Member Functions | Public Attributes | List of all members
WireCell::DfpGraph Struct Reference

#include <DfpGraph.h>

Classes

struct  EdgeProperty
 
struct  VertexProperty
 

Public Types

typedef boost::adjacency_list< boost::vecS, boost::setS, boost::directedS, VertexProperty, EdgePropertyGraph
 
typedef boost::graph_traits< Graph >::vertex_descriptor Vertex
 
typedef boost::graph_traits< Graph >::edge_descriptor Edge
 
typedef std::map< VertexProperty, VertexVertexPropertyMap
 
typedef std::tuple< VertexProperty, VertexProperty, EdgePropertyConnection
 

Public Member Functions

Vertex get_add_vertex (const VertexProperty &tn)
 
void configure (const Configuration &cfg)
 
Edge connect (const std::string &tail_type, const std::string &tail_name, int tail_port, const std::string &head_type, const std::string &head_name, int head_port)
 Explicitly connect one edge. More...
 
std::vector< Connectionconnections ()
 

Public Attributes

Graph graph
 
VertexPropertyMap vertex_property_map
 

Detailed Description

Definition at line 13 of file DfpGraph.h.

Member Typedef Documentation

Definition at line 50 of file DfpGraph.h.

typedef boost::graph_traits<Graph>::edge_descriptor WireCell::DfpGraph::Edge

Definition at line 46 of file DfpGraph.h.

typedef boost::adjacency_list<boost::vecS, boost::setS, boost::directedS, VertexProperty, EdgeProperty> WireCell::DfpGraph::Graph

Definition at line 43 of file DfpGraph.h.

typedef boost::graph_traits<Graph>::vertex_descriptor WireCell::DfpGraph::Vertex

Definition at line 45 of file DfpGraph.h.

Definition at line 48 of file DfpGraph.h.

Member Function Documentation

void DfpGraph::configure ( const Configuration cfg)

Configure with list of connection dictionaries like:

{ "tail": {"type":"TailType","name":"tailname", "port":0}, "head": {"type":"HeadType","name":"headname", "port":42} },

Only "type" key is required.

Definition at line 55 of file DfpGraph.cxx.

56 {
57  for (auto conn : cfg) {
58  auto tail = conn["tail"];
59  auto head = conn["head"];
60 
61  connect(get<std::string>(tail, "type"), get<std::string>(tail, "name"), get<int>(tail, "port"),
62  get<std::string>(head, "type"), get<std::string>(head, "name"), get<int>(head, "port"));
63  }
64 }
cfg
Definition: dbjson.py:29
Edge connect(const std::string &tail_type, const std::string &tail_name, int tail_port, const std::string &head_type, const std::string &head_name, int head_port)
Explicitly connect one edge.
Definition: DfpGraph.cxx:16
conn
Definition: dbjson.py:16
DfpGraph::Edge DfpGraph::connect ( const std::string tail_type,
const std::string tail_name,
int  tail_port,
const std::string head_type,
const std::string head_name,
int  head_port 
)

Explicitly connect one edge.

Definition at line 16 of file DfpGraph.cxx.

18 {
19 
20  VertexProperty tvp(tail_type, tail_name);
21  VertexProperty hvp(head_type, head_name);
22 
23  auto tv = get_add_vertex(tvp);
24  auto hv = get_add_vertex(hvp);
25 
26  EdgeProperty ep(tail_port, head_port);
27  Edge e; bool b;
28  std::tie(e, b) = boost::add_edge(tv, hv, ep, graph);
29  return e;
30 }
const double e
boost::graph_traits< Graph >::edge_descriptor Edge
Definition: DfpGraph.h:46
Vertex get_add_vertex(const VertexProperty &tn)
Definition: DfpGraph.cxx:5
static bool * b
Definition: config.cpp:1043
std::vector< DfpGraph::Connection > DfpGraph::connections ( )

Definition at line 32 of file DfpGraph.cxx.

33 {
34 
35  std::vector<Connection> ret;
36  auto vits = boost::vertices(graph);
37  for (auto v = vits.first; v != vits.second; ++v) {
38  auto vp = graph[*v];
39  auto eits = out_edges(*v, graph);
40 
41  if (eits.first == eits.second) continue;
42 
43  for (auto e = eits.first; e != eits.second; ++e) {
44  auto ep = graph[*e];
45 
46  auto other = target(*e, graph);
47  auto hp = graph[other];
48 
49  ret.push_back(std::make_tuple(vp,hp,ep));
50  }
51  }
52  return ret;
53 }
const double e
DfpGraph::Vertex DfpGraph::get_add_vertex ( const VertexProperty tn)

Definition at line 5 of file DfpGraph.cxx.

6 {
7  auto it = vertex_property_map.find(tn);
8  if (it != vertex_property_map.end()) {
9  return it->second;
10  }
11  auto v = add_vertex(tn, graph);
12  vertex_property_map[tn] = v;
13  return v;
14 }
VertexPropertyMap vertex_property_map
Definition: DfpGraph.h:54

Member Data Documentation

Graph WireCell::DfpGraph::graph

Definition at line 53 of file DfpGraph.h.

VertexPropertyMap WireCell::DfpGraph::vertex_property_map

Definition at line 54 of file DfpGraph.h.


The documentation for this struct was generated from the following files: