[BGL] there is no in_edges() function for adjacency_matrix<>

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[BGL] there is no in_edges() function for adjacency_matrix<>

Dmitry Bufistov
Hi,
A huge disappointment again came to me today. I used  
boost::adjacency<boost::directedS> class for representation of simple
Petri net. I was trying to define the following function
//////////////////////////////////////////
bool    if_enabled(transition_descriptor_t    tr, graph_t net) {
                assert((net[tr].m_node_type == TRANSITION) &&
"if_enabled called with non transition node");

                BGL_FORALL_INEDGES_T(tr, ed, net, graph_t)
                {
                    if (net[boost::source(ed, net)].m_tokens_number <
net[ed].m_weight) return false;
                }
                return true;
            }

//////////////////////////////////////////////////////////
But I failed because of lack of boost::in_edges() function  
specialization for type that I've  chosen.
Am I doing something wrong?
Any ideas how to implement my function in resonable way would be greatly
appreciated.
Note: all works fine with  "adjacency_list<vecS, vecS, bidirecrionalS>"

Many thanks in advance,
--dima
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [BGL] there is no in_edges() function for adjacency_matrix<>

David Abrahams
Dmitry Bufistov <[hidden email]> writes:

> Hi,
> A huge disappointment again came to me today. I used  
> boost::adjacency<boost::directedS> class for representation of simple
> Petri net. I was trying to define the following function
> //////////////////////////////////////////
> bool    if_enabled(transition_descriptor_t    tr, graph_t net) {
>                 assert((net[tr].m_node_type == TRANSITION) &&
> "if_enabled called with non transition node");
>
>                 BGL_FORALL_INEDGES_T(tr, ed, net, graph_t)
>                 {
>                     if (net[boost::source(ed, net)].m_tokens_number <
> net[ed].m_weight) return false;
>                 }
>                 return true;
>             }
>
> //////////////////////////////////////////////////////////
> But I failed because of lack of boost::in_edges() function  
> specialization for type that I've  chosen.
> Am I doing something wrong?
> Any ideas how to implement my function in resonable way would be greatly
> appreciated.
> Note: all works fine with  "adjacency_list<vecS, vecS, bidirecrionalS>"

By /definition/, BidirectionalGraph is a graph where you can enumerate
the incoming edges for any node.  Unless you specify bidirectionalS,
an adjacency list won't be a BidirectionalGraph, and you can't use
in_edges.  So everything is working just as I would expect it to.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [BGL] there is no in_edges() function for adjacency_matrix<>

Dmitry Bufistov
In reply to this post by Dmitry Bufistov
>
>
>Dmitry Bufistov <[hidden email]> writes:
>
>  
>
>>Hi,
>>A huge disappointment again came to me today. I used  
>>boost::adjacency<boost::directedS> class for representation of simple
>>Petri net. I was trying to define the following function
>>//////////////////////////////////////////
>>bool    if_enabled(transition_descriptor_t    tr, graph_t net) {
>>                assert((net[tr].m_node_type == TRANSITION) &&
>>"if_enabled called with non transition node");
>>
>>                BGL_FORALL_INEDGES_T(tr, ed, net, graph_t)
>>                {
>>                    if (net[boost::source(ed, net)].m_tokens_number <
>>net[ed].m_weight) return false;
>>                }
>>                return true;
>>            }
>>
>>//////////////////////////////////////////////////////////
>>But I failed because of lack of boost::in_edges() function  
>>specialization for type that I've  chosen.
>>Am I doing something wrong?
>>Any ideas how to implement my function in resonable way would be greatly
>>appreciated.
>>Note: all works fine with  "adjacency_list<vecS, vecS, bidirecrionalS>"
>>    
>>
>
>By /definition/, BidirectionalGraph is a graph where you can enumerate
>the incoming edges for any node.  Unless you specify bidirectionalS,
>an adjacency list won't be a BidirectionalGraph, and you can't use
>in_edges.  So everything is working just as I would expect it to.
>
>  
>
But what about boost::adjacency_matrix<boost::directedS> ?
Is there any way  to iterate  over  all  incoming edges?
Where I can read your answer before I recieve e-mail?
Time is very important )
Thank you,
--dima

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [BGL] there is no in_edges() function for adjacency_matrix<>

Cromwell Enage
--- Dmitry Bufistov wrote:
> But what about
> boost::adjacency_matrix<boost::directedS>?

No, that too has to be
boost::adjacency_matrix<boost::bidirectionalS>.

> Where I can read your answer before I recieve
> e-mail?

Try <http://lists.boost.org/Archives/boost-users/>

                              Cheers!
                              Cromwell D. Enage


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [BGL] there is no in_edges() function for adjacency_matrix<>

Doug Gregor-2
In reply to this post by Dmitry Bufistov

On Feb 6, 2006, at 8:04 AM, Dmitry Bufistov wrote:

> Hi,
> A huge disappointment again came to me today. I used
> boost::adjacency<boost::directedS> class for representation of simple
> Petri net. I was trying to define the following function
> //////////////////////////////////////////
> bool    if_enabled(transition_descriptor_t    tr, graph_t net) {
>                 assert((net[tr].m_node_type == TRANSITION) &&
> "if_enabled called with non transition node");
>
>                 BGL_FORALL_INEDGES_T(tr, ed, net, graph_t)
>                 {
>                     if (net[boost::source(ed, net)].m_tokens_number <
> net[ed].m_weight) return false;
>                 }
>                 return true;
>             }
>
> //////////////////////////////////////////////////////////
> But I failed because of lack of boost::in_edges() function
> specialization for type that I've  chosen.
> Am I doing something wrong?

No, you aren't doing anything wrong. The in_edges function was
accidentally left out of the adjacency_matrix class template. Nobody
has gotten around to implementing it yet.

> Any ideas how to implement my function in resonable way would be
> greatly
> appreciated.
> Note: all works fine with  "adjacency_list<vecS, vecS, bidirecrionalS>"

Right. adjacency_list gets a lot more use/attention than
adjacency_matrix, so it has a more complete feature set.

I usually try not to promise anything, but perhaps we can get
in_edges() implemented relatively quickly.

        Doug

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [BGL] there is no in_edges() function for adjacency_matrix<>

Dmitry Bufistov
In reply to this post by Dmitry Bufistov
--- Dmitry Bufistov wrote:
  
But what about
boost::adjacency_matrix<boost::directedS>?
    

No, that too has to be
boost::adjacency_matrix<boost::bidirectionalS>.
  
Unfortunately   this doesn't  help(
	
  
Where I can read your answer before I recieve
e-mail?
    

Try <http://lists.boost.org/Archives/boost-users/>

  
I can see my post's here http://lists.boost.org/boost-users/2006/02/date.php
but I can't reply on them(
                              Cheers!
                              Cromwell D. Enage
Thanks for the reply.

2 Doug,
Now I also can't use 

template <typename MutableGraph>
bool read_graphviz(std::istream& in, MutableGraph& graph,
                   dynamic_properties& dp,
                   std::string const& node_id = "node_id") ;
function for the same type. I think because  of following  declaractions in  "adjacency_matrix.hpp"
//////////////////////////////////////////////////
template <typename D, typename VP, typename EP, typename GP, typename A>
  inline typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
  add_vertex(adjacency_matrix<D,VP,EP,GP,A>& g) {
    // UNDER CONSTRUCTION
    assert(false);
    return *vertices(g).first;
  }

  template <typename D, typename VP, typename EP, typename GP, typename A>
  inline typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
  add_vertex(const VP& vp, adjacency_matrix<D,VP,EP,GP,A>& g) {
    // UNDER CONSTRUCTION
    assert(false);
    return *vertices(g).first;
  }

  template <typename D, typename VP, typename EP, typename GP, typename A>
  inline void
  remove_vertex(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
                adjacency_matrix<D,VP,EP,GP,A>& g)
  {
    // UNDER CONSTRUCTION
    assert(false);
  }
////////////////////////////////////////////////////////////

Will it be also implemented or how I can read my graph?
Many thanks for the reply,
--dima

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [BGL] there is no in_edges() function for adjacency_matrix<>

Doug Gregor-2

On Feb 7, 2006, at 7:14 AM, Dmitry Bufistov wrote:

>> --- Dmitry Bufistov wrote:
>>
>>> But what about
>>> boost::adjacency_matrix<boost::directedS>?
>>>
>> No, that too has to be
>> boost::adjacency_matrix<boost::bidirectionalS>.

I've attached an updated adjacency_matrix header (also in Boost CVS)
that implements the Bidirectional Graph requirements for
adjacency_matrix. It works with adjacency_matrix<directedS>; there is
no adjacency_matrix<bidirectionalS> because it isn't needed.

>  2 Doug,
>  Now I also can't use 
>
>  template <typename MutableGraph>
>  bool read_graphviz(std::istream& in, MutableGraph& graph,
>                     dynamic_properties& dp,
>                     std::string const& node_id = "node_id") ;
>  function for the same type. I think because  of following 
> declaractions in  "adjacency_matrix.hpp"
> [unimplemented add_vertex]
>  Will it be also implemented or how I can read my graph?
Adding vertices to an adjacency_matrix is *extremely* expensive,
requiring reallocation of the entire data structure. That functionality
may be implemented at some point, but I won't be able to do it any time
soon.

        Doug


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

adjacency_matrix.hpp (45K) Download Attachment