|
|
General help
- Undirected graph (undigraph)
- Data files
All data files for undirected graph are named as data.txt in output
directory.
You can find the output directory and data file after downloading
C/C++ samples.
Every line in data.file for undirected graph is in format
X,Y,weight
where
- X and Y are single capital characters from A to Z to identify 2 nodes.
- weight is an integer which represents weight between node X and node Y.
For example, the file may contain lines as:
A,H,8
A,B,12
A,F,5
First line indicates weight between node A and node H is 8,
Second line indicates weight between node A and node B is 12,
and so on.
Restrictions: for simple reason
- the data file can not contain blank line which contains white space.
- data lines can not contain white space also
You can modify function OpenAndReadDataFile() to remove the
restrictions.
- Executing
In output directory, you can find 3 files:
- project.exe
it is executable file compiled from source code by us on Windows OS.
you can re-compile on UNIX or other OS
- data.txt
it is data file, you can use yours but data file in executing command line
must be changed to your file name.
- run.bat
you can double click the file to run executable file if on Windows OS.
this file also shows you executing command line.
- C/C++ code to read the data file
- function OpenAndReadDataFile()
this function opens and reads data file to array of
DataLine filelines[MAXLINES];
where MAXLINES is defined as 2000, so it can read up to 2000 lines.
you can modify MAXLINES if you need more lines.
- struct DataLine
{
char chBegin; //a node
char chEnd; //another node
int iWeight; //weight between the 2 nodes
};
this struct holds info of one line of data file.
E.g. for first line of data file above, these fields are:
chBegin=A, chEnd=H, iWeight=8;
|
|
/
|
|