M
Mary Mikhail
Guest
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Map_Routing
{
class vertex
{
public int vertex_number;
public float x;
public float y;
public List<edge> edge_list;
public vertex(int v, float p1, float p2, List<edge> l)
{
vertex_number = v;
x = p1;
y = p2;
edge_list = l;
}
}
class edge
{
// edge between vertex v1 and vertex v2
public int v1;
public int v2;
public float road_len;
public int road_speed;
public edge(int var1, int var2, float var3, int var4)
{
v1 = var1;
v2 = var2;
road_len = var3;
road_speed = var4;
}
}
class Program
{
static void Main(string[] args)
{
List<vertex> graph = new List<vertex>();
StreamReader sr = new StreamReader("../../map1.txt");
string numOf_Vertex = sr.ReadLine();
string line = File.ReadLines("../../map1.txt").Skip(1).Take(1).First();
int count = int.Parse(numOf_Vertex);
while (count != 0)
{
line = sr.ReadLine();
string[] values = line.Split(' ');
// float s;
// s = float.Parse(values[2]); // it works here and print the correct values
// Console.WriteLine(s);
for(int i=0; i < int.Parse(numOf_Vertex);i++)
{
graph[0].vertex_number= int.Parse(values[0]); // it gives an exception here " index out of range"
graph[0].x = float.Parse(values[1]);
graph[0].y = float.Parse(values[2]);
}
count--;
}
while(count != 0)
{
for(int i=0; i<count; i++)
{
Console.WriteLine(graph.vertex_number);
Console.WriteLine(" ");
Console.WriteLine(graph.x);
Console.WriteLine(" ");
Console.WriteLine(graph.y);
Console.WriteLine(Environment.NewLine);
}
count--;
}
}
}
}
Continue reading...
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Map_Routing
{
class vertex
{
public int vertex_number;
public float x;
public float y;
public List<edge> edge_list;
public vertex(int v, float p1, float p2, List<edge> l)
{
vertex_number = v;
x = p1;
y = p2;
edge_list = l;
}
}
class edge
{
// edge between vertex v1 and vertex v2
public int v1;
public int v2;
public float road_len;
public int road_speed;
public edge(int var1, int var2, float var3, int var4)
{
v1 = var1;
v2 = var2;
road_len = var3;
road_speed = var4;
}
}
class Program
{
static void Main(string[] args)
{
List<vertex> graph = new List<vertex>();
StreamReader sr = new StreamReader("../../map1.txt");
string numOf_Vertex = sr.ReadLine();
string line = File.ReadLines("../../map1.txt").Skip(1).Take(1).First();
int count = int.Parse(numOf_Vertex);
while (count != 0)
{
line = sr.ReadLine();
string[] values = line.Split(' ');
// float s;
// s = float.Parse(values[2]); // it works here and print the correct values
// Console.WriteLine(s);
for(int i=0; i < int.Parse(numOf_Vertex);i++)
{
graph[0].vertex_number= int.Parse(values[0]); // it gives an exception here " index out of range"
graph[0].x = float.Parse(values[1]);
graph[0].y = float.Parse(values[2]);
}
count--;
}
while(count != 0)
{
for(int i=0; i<count; i++)
{
Console.WriteLine(graph.vertex_number);
Console.WriteLine(" ");
Console.WriteLine(graph.x);
Console.WriteLine(" ");
Console.WriteLine(graph.y);
Console.WriteLine(Environment.NewLine);
}
count--;
}
}
}
}
Continue reading...