Hi all! I need help understanding what my teacher expects from this project.
Here is the link to the instructions for the project: http://cs.ecu.edu/~karl/2530/spr18/Assn/Assn5/assn5.html

I wrote a little bit of code but i am stuck and dont know how to move forward

This is as far as ive gotten with the first function:

``````  void insertEdge(int u,int v,int w,int *g)
{
bool nullCheck = false
for (int i = 0; i <= maxEdges; i++)
{
if (g[i] == ' ')
{
nullCheck = true;
}
}
if (nullCheck)
{
g[0] = u;

}
}``````

Also im not looking for yall to write my code for me i just want to understand how to approch this project.

While I can't say much without more detail about the rest of your code, I am pretty sure that, as you seem to suspect, you have either missed or misunderstood part of the assignment. I may be wrong, but based on the description of the problem, it appears that the function signature should be closer to (but not quite; see further down for the full explanation):

``void insertEdge(int u, int v, int w, Graph& g);``

Where `Graph` is the second of the two `struct` types described in section 4 of the assignment:

An object of type `Graph` represents a weighted graph. It has four fields:

1. the number of vertices in the graph,
2. the number of edges in the graph,
3. an array of `Edge` structures that holds the edges,
4. the physical size of that array of edges.

Include a constructor `Graph(nv)` that yields a graph with `nv` vertices and no edges. The constructor must create the array of edges.

Note that the `Graph` type requires the `Edge` type to already be defined, as each `Graph` object is has an array of `Edge`s as a component.

So before you do anything else, if you haven't done so already, you need to define the `Edge` and `Graph` structures. I assume you've covered structure types already, but the assignment does give a link to the previous lecture notes on `struct` types, as well as the expected naming and documentation conventions.

Note as well that the assignment specifies that the argument `g` needs to be passed as a reference; while one could argue that a pointer can be used for this purpose instead to the same effect, it isn't what the assignment asks for - references are (usually) implemented as pointers, but have restrictions that pointers don't, which are meant to help catch certain kinds of errors. I'm guessing that the professor is expecting you to follow good code practices on this.

Speaking of which, I was suspect that the function signature for `insertGraph()` actually should be:

``void insertEdge(vertexNum u, vertexNum v, int w, Graph& g);``

given that the assignment does mention using these two `typedef`s for the vertex and edge identifiers:

``````  typedef int vertexNum;
typedef int edgeNum;``````

...which are used to dimensionally differentiate the two types of values (even though they are both represented as `int`s). You might want to confirm this with the good Dr. Abrahamson or one of his TAs before proceeding, however.

Now, were I designing this, I would also declare a type `Weight` just to indicate that `w` and similar values are specifically weights rather than non-specific integer values, but that isn't actually necessary in the assignment as given. I don't know if your professor would see this as a good design choice, or as going outside the specification.

(But then, I probably would also declare all three such `typedef` as `unsigned int` instead of `int`, on the assumption that you would never have a negative count or weight, and declare the function as `bool` rather than `void` so I could return `false` if the insert fails, but that isn't what the assignment asks for.)

commented: Nice! +15