# Creating an Interactive Module that plots a graph and a highlighted vertex

For an assignment, I have to do the following:

Build an interactive model with two controls, n and u, that generates a random graph called K with n vertices and 2n edges and highlights vertex u of graph K. When the user selects a different vertex u of K, you display graph K with vertex u shown with a different color and with a different size.

At the moment, my code is as follows:

K = RandomGraph[{n}, {2 n}];
Manipulate[HighlightGraph[K, {u}], {n, 1, 10, 1}, {u, 1, n, 1}]


I think I need to state that u is a vertex, but unsure how to fix. Any help is appreciated.

Create a function using SetDelayed to evaluate RandomGraph every time you call the function. Here, SeedRandom is used, so that every time RandomGraph is called for a given n, it gives the same result.

graph[n_, u_, size_] := With[{},
SeedRandom[1000];
RandomGraph[{n, 2 n}, VertexSize -> {u -> size}]]


Then, in the Manipulate to change the color, RandomColor[] function can be used in the Style attribute.

Manipulate[
HighlightGraph[
graph[n, u, u/(5 n)], {Style[u, RandomColor[n][[u]]]}], {n, 5, 15,
1}, {u, 1, n, 1}, ControlType -> LabeledSlider]


Note: To get 2n edges, value of n should be >= 5.