21.5 Utilize more graph operations - Video Tutorials & Practice Problems
Video duration:
4m
Play a video:
<v Voiceover>Another important</v> measurement for networks is the diameter. So let's calculate that. We'll say d gets get.diameter, of flights. This is a path along the graph. And to make our graph easier to see, let's change some of the attributes. For the vertices, we'll make them all size four. (keyboard clicking) Now for the edges, we will make them have a width of 1, and a color of dark grey. Then for the edges that are along the diameter, we'll make their widths 3 and their colors red. So we'll say E of flights, just for the edges that are along the path d, width is 3, and similarly for the edges of flights along the path d, color gets red in quotes. So now if we plot this, and we will say vertex.label equals NA. And now we have this nice graph showing us all the paths, but the ones along the diameter is in red. Nice easy way to visualize your graph. Another thing we can plot is the graph coreness. So let's calculate that. So we'll say cores gets graph.coreness of flights. We will then extract the two core graph, and that will eliminate dependence and pendant chains. So we will say g2 gets induced.subraph of flights, and then we will say as.vector of which cores greater than 1. We will now go ahead and make the vertices for this graph to have a size of four, so as you can see, and we'll say plot of g2. And we will see we have this plot showing off the coreness of the graph. And sometimes it might be helpful to delete edges in a graph that's actually a fairly simple process. To make sure we don't screw up our original graph, we will say flights4 gets flights. Then we will say flights4 gets delete.edges of flights4, say which edges of flights4, has a time of less than 150. We can now get the edge count of flights4, and see that it's 155, and if we plot it, we can see that it's a different graph. Those are still some colors from before, that's because we built it off of flights which already had some colors built into it. But you can see it's a different graph because we deleted some edges. There are many ways to measure your graph, and also many ways to work on your graph. We have the same things such as the diameter, degree, coreness, and we even still have to delete edges. It's all very important in doing your analysis.