MATLAB: Plotting an undirected graph gives me only unconnected dots.

graphgraph theoryplotundirected graph

I have an undirected graph of 7618 edges that I want to plot. I put the first set of nodes of each edge in nodes1 and the other set of nodes of each edge in nodes2 and:
G= graph(nodes1,nodes2)
plot(G)
This is the plot I get
untitled.png
Why aren't the nodes connected like they are supposed to except from those in the bottom left? How do I fix it to get the results I want?
Matlab R2016a

Best Answer

I found a solution for deleting the isolated nodes. First you find the degree matrix for every node. The elements which have a degree of zero are isolated nodes. Therefore your next move is to find the indexes of those elements and the delete them from the graph:
D = degree(G);
index = find(D == 0);
D(index) = [];
G = rmnode(G,index);