参考文件: http : //snap.stanford.edu/data/wiki-Vote.txt.gz
(它是一个磁带存档,其中包含一个名为 的文件Wiki-Vote.txt)
文件中的前几行包含以下内容, head -n 10 Wiki-Vote.txt
# Directed graph (each unordered pair of nodes is saved once): Wiki-Vote.txt
# Wikipedia voting on promotion to administratorship (till January 2008).
# Directed edge A->B means user A voted on B becoming Wikipedia administrator.
# Nodes: 7115 Edges: 103689
# FromNodeId ToNodeId
30 1412
30 3352
30 5254
30 5543
30 7478
3 28
Run Code Online (Sandbox Code Playgroud)
我想找到图中的节点数(尽管它已经在第 3 行中给出)。我运行了以下命令,
awk '!/^#/ { print $1; print $2; }' Wiki-Vote.txt …Run Code Online (Sandbox Code Playgroud)