• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python networkx.karate_club_graph函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中networkx.karate_club_graph函数的典型用法代码示例。如果您正苦于以下问题:Python karate_club_graph函数的具体用法?Python karate_club_graph怎么用?Python karate_club_graph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了karate_club_graph函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_edge_num_attribute

    def test_edge_num_attribute(self):

        g = nx.karate_club_graph()
        attr = {(u, v): {"even": int((u+v) % 10)} for (u, v) in g.edges()}
        nx.set_edge_attributes(g, attr)

        model = gc.CompositeModel(g)
        model.add_status("Susceptible")
        model.add_status("Infected")

        c = cpm.EdgeNumericalAttribute("even", value=0, op="==", probability=1)
        model.add_rule("Susceptible", "Infected", c)

        config = mc.Configuration()
        config.add_model_parameter('percentage_infected', 0.1)

        model.set_initial_status(config)
        iterations = model.iteration_bunch(10)
        self.assertEqual(len(iterations), 10)

        model = gc.CompositeModel(g)
        model.add_status("Susceptible")
        model.add_status("Infected")

        c = cpm.EdgeNumericalAttribute("even", value=[3, 10], op="IN", probability=1)
        model.add_rule("Susceptible", "Infected", c)

        config = mc.Configuration()
        config.add_model_parameter('percentage_infected', 0.1)

        model.set_initial_status(config)
        iterations = model.iteration_bunch(10)
        self.assertEqual(len(iterations), 10)
开发者ID:GiulioRossetti,项目名称:ndlib,代码行数:33,代码来源:test_compartment.py


示例2: main

def main():
    # Load the karate.GraphML and store that into a g
    g =nx.karate_club_graph()
    data = json_graph.node_link_data(g)

    with open ('graph.json' , 'w') as f:
        json.dump(data, f, indent=1)
开发者ID:bbreddy123,项目名称:cs595-f14,代码行数:7,代码来源:intialJSON.py


示例3: test_nodes_all_labeled

 def test_nodes_all_labeled(self):
     G = nx.karate_club_graph()
     label_name = 'club'
     predicted = node_classification.local_and_global_consistency(
         G, alpha=0, label_name=label_name)
     for i in range(len(G)):
         assert_equal(predicted[i], G.node[i][label_name])
开发者ID:ProgVal,项目名称:networkx,代码行数:7,代码来源:test_local_and_global_consistency.py


示例4: test_run

 def test_run(self):
     karate = nx.karate_club_graph()
     louvain = wm.LouvainCommunityDetection(karate)
     final_partitions = louvain.run()
     self.assertEqual(final_partitions[-1].modularity() > .38,
                      True)
     self.assertEqual(len(final_partitions), 2)
开发者ID:cgallen,项目名称:brainx,代码行数:7,代码来源:test_weighted_modularity.py


示例5: test_clustering_integer_nodes

 def test_clustering_integer_nodes(self):
     # This tests an error that would happen when a node had an integer value
     # greater than the size of the graph
     orig_club = nx.karate_club_graph()
     club = nx.relabel_nodes(orig_club, { n: n + 5 for n in orig_club.nodes() })
     dendrogram = GreedyAgglomerativeClusterer().cluster(club)
     dendrogram.clusters() # This would crash
开发者ID:MSeal,项目名称:agglom_cluster,代码行数:7,代码来源:hac_test.py


示例6: test_nodes_all_labeled

 def test_nodes_all_labeled(self):
     G = nx.karate_club_graph()
     label_name = 'club'
     predicted = node_classification.harmonic_function(
         G, label_name=label_name)
     for i in range(len(G)):
         assert_equal(predicted[i], G.node[i][label_name])
开发者ID:ProgVal,项目名称:networkx,代码行数:7,代码来源:test_harmonic_function.py


示例7: test_graphs_karate

def test_graphs_karate():
    G = nx.karate_club_graph()
    nx.draw(G, with_labels=True, node_color="lightblue", edge_color="grey")
    plt.show()
    # plt.savefig("karate.pdf")
    print(G.number_of_edges())
    print(G.number_of_nodes())
    print(G.degree(0) is G.degree()[0])
开发者ID:piotrbla,项目名称:pyExamples,代码行数:8,代码来源:bird_tracking.py


示例8: test_net_load

    def test_net_load(self):
        base = os.path.dirname(os.path.abspath(__file__))

        g = nx.karate_club_graph()
        fname = "%s/edge.txt" % base
        nx.write_edgelist(g, fname)

        query = "LOAD_NETWORK g1 FROM %s\n" \
                "\n" \
                "MODEL model1\n" \
                "\n" \
                "STATUS Susceptible\n" \
                "\n" \
                "STATUS Infected\n" \
                "\n" \
                "STATUS Removed\n" \
                "\n" \
                "COMPARTMENT c1\n" \
                "TYPE NodeStochastic\n" \
                "PARAM rate 0.1\n" \
                "TRIGGER Infected\n" \
                "\n" \
                "COMPARTMENT c2\n" \
                "TYPE NodeStochastic\n" \
                "PARAM rate 0.1\n" \
                "COMPOSE c1\n" \
                "TRIGGER Infected\n" \
                "\n" \
                "COMPARTMENT c3\n" \
                "TYPE NodeStochastic\n" \
                "PARAM rate 0.1\n" \
                "\n" \
                "RULE\n" \
                "FROM Susceptible\n" \
                "TO Infected\n" \
                "USING c2\n" \
                "\n" \
                "RULE\n" \
                "FROM Infected\n" \
                "TO Removed\n" \
                "USING c3\n" \
                "\n" \
                "INITIALIZE\n" \
                "SET Infected 0.1\n" \
                "\n" \
                "EXECUTE model1 ON g1 FOR 10" % fname

        parser = ep.ExperimentParser()
        parser.set_query(query)
        parser.parse()
        iterations = parser.execute_query()

        try:
            os.remove("%s/edge.txt" % base)
        except OSError:
            pass

        self.assertIn('trends', iterations[0])
开发者ID:GiulioRossetti,项目名称:ndlib,代码行数:58,代码来源:test_parser.py


示例9: test_karate_1

def test_karate_1():
    karate_k_num = {0: 4, 1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2,
                    10: 3, 11: 1, 12: 2, 13: 4, 14: 2, 15: 2, 16: 2, 17: 2, 18: 2,
                    19: 3, 20: 2, 21: 2, 22: 2, 23: 3, 24: 3, 25: 3, 26: 2, 27: 3,
                    28: 3, 29: 3, 30: 4, 31: 3, 32: 4, 33: 4}
    G = nx.karate_club_graph()
    k_comps = k_components(G)
    k_num = build_k_number_dict(k_comps)
    assert_equal(karate_k_num, k_num)
开发者ID:Jverma,项目名称:networkx,代码行数:9,代码来源:test_kcomponents.py


示例10: test_karate_club_graph_cutset

 def test_karate_club_graph_cutset(self):
     G = nx.karate_club_graph()
     nx.set_edge_attributes(G, 1, 'capacity')
     T = nx.gomory_hu_tree(G)
     assert_true(nx.is_tree(T))
     u, v = 0, 33
     cut_value, edge = self.minimum_edge_weight(T, u, v)
     cutset = self.compute_cutset(G, T, edge)
     assert_equal(cut_value, len(cutset))
开发者ID:aparamon,项目名称:networkx,代码行数:9,代码来源:test_gomory_hu.py


示例11: test_default_flow_function_karate_club_graph

 def test_default_flow_function_karate_club_graph(self):
     G = nx.karate_club_graph()
     nx.set_edge_attributes(G, 1, 'capacity')
     T = nx.gomory_hu_tree(G)
     assert_true(nx.is_tree(T))
     for u, v in combinations(G, 2):
         cut_value, edge = self.minimum_edge_weight(T, u, v)
         assert_equal(nx.minimum_cut_value(G, u, v),
                      cut_value)
开发者ID:aparamon,项目名称:networkx,代码行数:9,代码来源:test_gomory_hu.py


示例12: main

def main():
    G = nx.karate_club_graph()
    N = NewmanGreedy(G)
    print N.quality_history
    try:
        N.plot_dendrogram()
        N.plot_quality_history("Karate", os.path.join(os.path.dirname(__file__), "pics", "karate"))
    except:
        pass
开发者ID:Libardo1,项目名称:agglom_cluster,代码行数:9,代码来源:agglomod.py


示例13: test_biconnected_karate

def test_biconnected_karate():
    K = nx.karate_club_graph()
    answer = [{0, 1, 2, 3, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19,
               20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33},
              {0, 4, 5, 6, 10, 16},
              {0, 11}]
    bcc = list(nx.biconnected_components(K))
    assert_components_equal(bcc, answer)
    assert_equal(set(nx.articulation_points(K)), {0})
开发者ID:AmesianX,项目名称:networkx,代码行数:9,代码来源:test_biconnected.py


示例14: test_biconnected_karate

def test_biconnected_karate():
    K = nx.karate_club_graph()
    answer = [set([0, 1, 2, 3, 7, 8, 9, 12, 13, 14, 15, 17, 18, 19,
                20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]),
                set([0, 4, 5, 6, 10, 16]),
                set([0, 11])]
    bcc = list(biconnected.biconnected_components(K))
    bcc.sort(key=len, reverse=True)
    assert_true(list(biconnected.biconnected_components(K)) == answer)
    assert_equal(list(biconnected.articulation_points(K)),[0])
开发者ID:NikitaVAP,项目名称:pycdb,代码行数:10,代码来源:test_biconnected.py


示例15: main

def main():
    graph = nx.karate_club_graph();
    dendrogram = GreedyAgglomerativeClusterer().cluster(graph)
    print dendrogram.quality_history
    print dendrogram.clusters()
    try:
        dendrogram.plot(os.path.join(os.path.dirname(__file__), '..', 'pics', 'karate_dend.png'), show=False)
        dendrogram.plot_quality_history('Karate', os.path.join(os.path.dirname(__file__), '..', 'pics', 'karate'), show=False)
    except:
        pass
开发者ID:babaksoleimani,项目名称:agglom_cluster,代码行数:10,代码来源:cluster_runner.py


示例16: main

def main():
    graph = nx.karate_club_graph();
    newman = NewmanGreedy(graph)
    print newman.quality_history
    print newman.get_clusters()
    try:
        newman.plot_dendrogram(os.path.join(os.path.dirname(__file__), '..', 'pics', 'karate_dend.png'), show=False)
        newman.plot_quality_history('Karate', os.path.join(os.path.dirname(__file__), '..', 'pics', 'karate'), show=False)
    except:
        pass
开发者ID:harixxy,项目名称:agglom_cluster,代码行数:10,代码来源:agglomod.py


示例17: write_karate_adj_mat_by_nx

def write_karate_adj_mat_by_nx():
	g = nx.karate_club_graph()
	mat = np.zeros((34, 34))
	for edge in nx.edges(g):
		node0 = int(edge[0])
		node1 = int(edge[1])
		mat[node0][node1] = 1
		mat[node1][node0] = 1

	np.savetxt("karate_adj_mat.csv", mat, fmt="%.0f", delimiter=",")
开发者ID:fengjackling,项目名称:MarkovChainNetworkClustering,代码行数:10,代码来源:various_tester.py


示例18: test_postprocessing

def test_postprocessing():
    G = nx.karate_club_graph()
    prediction_all_links = CommonNeighbours(G)()
    prediction_only_new_links = CommonNeighbours(G, excluded=G.edges())()

    for link, score in six.iteritems(prediction_all_links):
        if G.has_edge(*link):
            assert_not_in(link, prediction_only_new_links)
        else:
            assert_equal(score, prediction_only_new_links[link])
开发者ID:TythonLee,项目名称:linkpred,代码行数:10,代码来源:test_predictors_base.py


示例19: setUp

 def setUp(self):
     self.Gnp = nx.gnp_random_graph(20, 0.8)
     self.Anp = _AntiGraph(nx.complement(self.Gnp))
     self.Gd = nx.davis_southern_women_graph()
     self.Ad = _AntiGraph(nx.complement(self.Gd))
     self.Gk = nx.karate_club_graph()
     self.Ak = _AntiGraph(nx.complement(self.Gk))
     self.GA = [(self.Gnp, self.Anp),
                (self.Gd, self.Ad),
                (self.Gk, self.Ak)]
开发者ID:yamaguchiyuto,项目名称:networkx,代码行数:10,代码来源:test_kcomponents.py


示例20: loadData

def loadData(nameGraph):
    global gt
    global problem_name
    problem_name=nameGraph
    if (nameGraph==karate_club):
        graph=nx.karate_club_graph()  #standard graph in networkx
        gt=ksgt
    elif (nameGraph==dolphins):
        graph=nx.read_gml('..\data\dolphins\dolphins.gml')
        gt=dgt
    return graph
开发者ID:picarus,项目名称:Memetic-Algorithm-for-Clustering,代码行数:11,代码来源:cimemetics.py



注:本文中的networkx.karate_club_graph函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python networkx.katz_centrality函数代码示例发布时间:2022-05-27
下一篇:
Python networkx.k_core函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap