Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6227621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:15:20+00:00 2026-05-24T09:15:20+00:00

I am not quite sure why the edge_array that is created is being shown

  • 0

I am not quite sure why the edge_array that is created is being shown as a undefined identifier when being used in the button click handler I am new to cli/c++ silly mistakes will be a likely cause on further note I am using VS2010 and I am also using boost unmanaged code in the mix of the cli managed stuff any help will be much appreciated

namespace Prototype {
    //using namespace boost;
    using namespace boost::graph;
    using namespace boost::numeric::ublas;
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace System::Runtime::InteropServices;
    using namespace msclr::interop;

    /// <summary>
    /// Summary for Form1
    /// </summary>
    //graph properties types
    typedef boost::property<boost::edge_weight_t, double> EdgeWeightProperty;
    typedef boost::property<boost::vertex_name_t, std::string, boost::property<boost::vertex_potential_t, int, boost::property<boost::vertex_update_t, double> > > StationProperties;

    //graph type
    typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, StationProperties, EdgeWeightProperty> Graph;

    //instantiation
    Graph g;

    // Property accessors
    boost::property_map<Graph, boost::vertex_name_t>::type station_name = get(boost::vertex_name, g);
    boost::property_map<Graph, boost::vertex_potential_t>::type station_capacity = get(boost::vertex_potential, g);
    boost::property_map<Graph, boost::vertex_update_t>::type station_update = get(boost::vertex_update, g);
    boost::property_map<Graph, boost::edge_weight_t>::type edge_distance = get(boost::edge_weight, g);

    //vertex descriptor
    typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;

    //transition matrix definition and station vector definition
    matrix<double> trans(6,6);
    vector<double> stat(6);

    bool inserted;
    int counter = 0;

    typedef boost::graph_traits<Graph>::edge_descriptor edge_descriptor;

    edge_descriptor e;

    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();

            //station vector definition
            stat(0) = 1000;
            stat(1) = 1000;
            stat(2) = 1000;
            stat(3) = 1000;
            stat(4) = 1000;
            stat(5) = 1000;

            //transition matrix
            trans(0,0) = 0; trans(0,1) = 1; trans(0,2) = 0; trans(0,3) = 0; trans(0,4) = 0; trans(0,5) = 0;
            trans(1,0) = 0.25; trans(1,1) = 0; trans(1,2) = 0.75; trans(1,3) = 0; trans(1,4) = 0; trans(1,5) = 0;
            trans(2,0) = 0; trans(2,1) = 0.33; trans(2,2) = 0; trans(2,3) = 0.33; trans(2,4) = 0.33; trans(2,5) = 0;
            trans(3,0) = 0; trans(3,1) = 0; trans(3,2) = 0.75; trans(3,3) = 0; trans(3,4) = 0; trans(3,5) = 0.25;
            trans(4,0) = 0; trans(4,1) = 0; trans(4,2) = 0.75; trans(4,3) = 0; trans(4,4) = 0; trans(4,5) = 0.25;
            trans(5,0) = 0; trans(5,1) = 0; trans(5,2) = 0; trans(5,3) = 0.5; trans(5,4) = 0.5; trans(5,5) = 0;

            //station graph declerations

            Vertex u0;
            u0 = add_vertex(g);
            station_name[u0] = "Kennington";
            station_capacity[u0] = 2000;
            station_update[u0] = stat(0);

            Vertex u1;
            u1 = add_vertex(g);
            station_name[u1] = "Elephant & Castle";
            station_capacity[u1] = 2000;
            station_update[u1] = stat(1);

            Vertex u2;
            u2 = add_vertex(g);
            station_name[u2] = "London Bridge";
            station_capacity[u2] = 3000;
            station_update[u2] = stat(2);

            Vertex u3;
            u3 = add_vertex(g);
            station_name[u3] = "Bank";
            station_capacity[u3] = 3000;
            station_update[u3] = stat(3);

            Vertex u4;
            u4 = add_vertex(g);
            station_name[u4] = "Borough";
            station_capacity[u4] = 2000;
            station_update[u4] = stat(4);

            Vertex u5;
            u5 = add_vertex(g);
            station_name[u5] = "Oval";
            station_capacity[u5] = 3000;
            station_update[u5] = stat(5);

            typedef std::pair<int,int> Edge;
            Edge edge_array[] = {
                Edge(u0, u0), Edge(u0, u1),Edge(u0, u2),Edge(u0, u3),Edge(u0, u4),Edge(u0, u5),
                Edge(u1, u0), Edge(u1, u1),Edge(u1, u2),Edge(u1, u3),Edge(u1, u4),Edge(u1, u5),
                Edge(u2, u0), Edge(u2, u1),Edge(u2, u2),Edge(u2, u3),Edge(u2, u4),Edge(u2, u5),
                Edge(u3, u0), Edge(u3, u1),Edge(u3, u2),Edge(u3, u3),Edge(u3, u4),Edge(u3, u5),
                Edge(u4, u0), Edge(u4, u1),Edge(u4, u2),Edge(u4, u3),Edge(u4, u4),Edge(u4, u5),
                Edge(u5, u0), Edge(u5, u1),Edge(u5, u2),Edge(u5, u3),Edge(u5, u4),Edge(u5, u5)
            };
        //all other declerations

    private:
        void Build_Click(System::Object^  sender, System::EventArgs^  e) {
            //station_name[u0] = marshal_as<std::string> (this->NameBox0->Text);
            station_name[0] = marshal_as<std::string> (this->NameBox0->Text);
            station_name[1] = marshal_as<std::string> (this->NameBox1->Text);
            station_name[2] = marshal_as<std::string> (this->NameBox2->Text);
            station_name[3] = marshal_as<std::string> (this->NameBox3->Text);
            station_name[4] = marshal_as<std::string> (this->NameBox4->Text);
            station_name[5] = marshal_as<std::string> (this->NameBox5->Text);

            station_capacity[0] = System::Convert::ToInt32(this->Capbox0->Text);
            station_capacity[1] = System::Convert::ToInt32(this->Capbox1->Text);
            station_capacity[2] = System::Convert::ToInt32(this->Capbox1->Text);
            station_capacity[3] = System::Convert::ToInt32(this->Capbox1->Text);
            station_capacity[4] = System::Convert::ToInt32(this->Capbox1->Text);
            station_capacity[5] = System::Convert::ToInt32(this->Capbox5->Text);

            for (unsigned i = 0; i < trans.size1 (); ++ i){
                for (unsigned j = 0; j < trans.size2 (); ++ j){
                    if (trans(i,j) > 0.1)
                    {
                        boost::tie(e, inserted) = boost::add_edge(edge_array[counter].first,edge_array[counter].second,g);
                        edge_distance[e] = trans(i,j);
                    }
                    ++counter;
                }
            }
        }
    };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:15:20+00:00Added an answer on May 24, 2026 at 9:15 am

    You are both declaring and initialising the edge_array within the Form1 constructor. Since you declare the variable within the scope of Form1() it only exists within the scope of Form1().

    Outside of Form1() edge_array is undefined.

    To make edge_array visible to Button_Click you need to declare it outside the class like vector<double> stat is declared or declare it within the class like other class member variables – somewhere in the //all other declerations area.

    You can still initialise the array within the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not quite sure how to phrase the title here. The issue is that I
Not quite sure if I asked correctly, but basically I have an array that
Not quite sure how to troubleshoot this. I'm maintaining an ASP site, its mostly
Not quite sure how to word this question. I am wondering if there is
I'm not quite sure if this is possible, or falls into the category of
I'm not quite sure if this is specific to Sun Java Systems Application Server
I'm not quite sure how this happened, but somehow a completely empty hierarchy of
I'm not quite sure when selecting only a certain number of rows would be
I'm not quite sure how to approach this issue: I am creating a web
I'm not quite sure how to do this. Let's say I have 2 associative

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.