Situation
I'd like analyse my web site with CommunityGraphPlot
as follows:
Step 1: Define a function to scrape the all the webpages from expected website.
netScrape[url_] :=
Union[Flatten[Thread[# -> Import[#, "Hyperlinks"]]& /@ Last/@ url]]
Step 2: Define a function to crawl the topology, down to the depth I want to dig.
webCrawler[rootUrl_, depth_] :=
Flatten[Rest[NestList[netScrape, {"" -> rootUrl}, depth]]]
Step 3: crawl the website.
netFriends = webCrawler["http://bitwan.science", 2]
Step 4: Plot the community.
CommunityGraphPlot[netFriends]
Debug
I ran the above code, step1 through step4. However, I get a warning saying
A graph object is expected at position 1 in EdgeList ...
Checking the data type of netFriends
with netFriends // FullForm
, confirms it is a list of rules.
I refer to Mathematica documentation on CommunityGraphPlot
. I find it says that it's legal when using
CommunityGraphPlot[{v1 -> v2, v3 -> v4}, ... ]
My Question
I am confused by this situation. As the netFriends
is a list of rules, why doesn't CommunityGraphPlot[netFriends]
work?
Can anyone tell me why my codes produced the error I am seeing?
?dl=1
in the Dropbox URL for automatic download. I edited it for you. Please keep that file there forever, as this question will be visited by other users in the future. $\endgroup$StringQ@friends
giveTrue
. You have imported the data as a single String, not a table of rules. $\endgroup$