network

C

Complex Humans

I have a little problem,
that i'd like to read your comments and suggestions
I create a network of 5-10 nodes - a weighted digraph
which all nodes are connected randomly at runtime.
Loops are allowed in the graph.
Is it possible to *hash* pairs of nodes
as well as their costs by use of the following snip,


template<typename T>
struct HashNodes{
T startNode;
T endNode;
int weight[];
};

This is clumpsy and possibly won't work
but I am clueless as of where should I go
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

I have a little problem,
that i'd like to read your comments and suggestions
I create a network of 5-10 nodes - a weighted digraph
which all nodes are connected randomly at runtime.
Loops are allowed in the graph.
Is it possible to *hash* pairs of nodes
as well as their costs by use of the following snip,

template<typename T>
struct HashNodes{
T startNode;
T endNode;
int weight[];

};

This is clumpsy and possibly won't work
but I am clueless as of where should I go

Do I understand you correctly that you want a way to quickly get the
weight given two nodes? In that case I would use
std::map<std::pair<Node, Node>, double> and create a functor which
given two std::paid<Node, Node> orders them in some way (on other way
implements a less than function for pairs of std::paid<Node, Node>.
Exactly how this is done is not particularly important, and if you
have some ID for each node there should be no problem.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

I have a little problem,
that i'd like to read your comments and suggestions
I create a network of 5-10 nodes - a weighted digraph
which all nodes are connected randomly at runtime.
Loops are allowed in the graph.
Is it possible to *hash* pairs of nodes
as well as their costs by use of the following snip,

template<typename T>
struct HashNodes{
T startNode;
T endNode;
int weight[];

};

This is clumpsy and possibly won't work
but I am clueless as of where should I go

Do I understand you correctly that you want a way to quickly get the
weight given two nodes? In that case I would use
std::map<std::pair<Node, Node>, double> and create a functor which
given two std::paid<Node, Node> orders them in some way (on other way
implements a less than function for pairs of std::paid<Node, Node>.

Hmm, not even I can parse the last bit of that. What I meant was to say
that you should implement a 'less than' function so that you can compare
two std::pair<Node, Node> objects and tell which of them is the
smallest, for some definition of smallest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,065
Members
47,672
Latest member
svaraho

Latest Threads

Top