[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] largest connected component code for python
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] largest connected component code for python |
Date: |
Sun, 23 Jan 2011 22:25:37 +0100 |
Hi Simone,
g.clusters() should produce an instance of VertexClustering if g is an instance
of igraph.Graph; are you sure that g is an instance of Graph and not GraphBase
(which should not be used directly)?
--
Tamas
On 23 Jan 2011, at 22:17, Simone Gabbriellini wrote:
> Hi List,
>
> I am trying to translate this code for largest connected component also for
> python (0.6 version):
>
> R
> gclust<-clusters(g, mode='weak')
> lcc<-induced.subgraph(g, V(g)[which(gclust$membership ==
> which.max(gclust$csize))])
>
> Python
> clust = g.clusters(mode='weak')
> lcc = clust.giant()
>
> But the result is that clust is just a list and that clust.giant() cannot be
> executed.
>
> BTW, if I use g.clusters(mode='weak') or g.clusters(mode='strong') it
> produces just a membership list, but if I call simply g.clusters() it
> produces this error:
>
> In [10]: g.clusters()
> /Applications/Enthought/PyLab.app/Contents/MacOS/startup.command: line 2:
> 55739 Segmentation fault
> /Library/Frameworks/Python.framework/Versions/6.2/bin/ipython -pylab
> logout
>
> below is my network, thanks for any help!
>
> best,
> Simone
>
> <?xml version="1.0" encoding="UTF-8"?>
> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
> http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
> <!-- Created by igraph -->
> <key id="creation" for="node" attr.name="creation" attr.type="double"/>
> <key id="type" for="node" attr.name="type" attr.type="double"/>
> <key id="name" for="node" attr.name="name" attr.type="double"/>
> <key id="creation" for="edge" attr.name="creation" attr.type="double"/>
> <graph id="G" edgedefault="undirected">
> <node id="n0">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">1</data>
> </node>
> <node id="n1">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">2</data>
> </node>
> <node id="n2">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">3</data>
> </node>
> <node id="n3">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">4</data>
> </node>
> <node id="n4">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">5</data>
> </node>
> <node id="n5">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">6</data>
> </node>
> <node id="n6">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">7</data>
> </node>
> <node id="n7">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">8</data>
> </node>
> <node id="n8">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">9</data>
> </node>
> <node id="n9">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">10</data>
> </node>
> <node id="n10">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">11</data>
> </node>
> <node id="n11">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">12</data>
> </node>
> <node id="n12">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">13</data>
> </node>
> <node id="n13">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">14</data>
> </node>
> <node id="n14">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">15</data>
> </node>
> <node id="n15">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">16</data>
> </node>
> <node id="n16">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">17</data>
> </node>
> <node id="n17">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">18</data>
> </node>
> <node id="n18">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">19</data>
> </node>
> <node id="n19">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">20</data>
> </node>
> <node id="n20">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">21</data>
> </node>
> <node id="n21">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">22</data>
> </node>
> <node id="n22">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">23</data>
> </node>
> <node id="n23">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">24</data>
> </node>
> <node id="n24">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">25</data>
> </node>
> <node id="n25">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">26</data>
> </node>
> <node id="n26">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">27</data>
> </node>
> <node id="n27">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">28</data>
> </node>
> <node id="n28">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">29</data>
> </node>
> <node id="n29">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">30</data>
> </node>
> <node id="n30">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">31</data>
> </node>
> <node id="n31">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">32</data>
> </node>
> <node id="n32">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">33</data>
> </node>
> <node id="n33">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">34</data>
> </node>
> <node id="n34">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">35</data>
> </node>
> <node id="n35">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">36</data>
> </node>
> <node id="n36">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">37</data>
> </node>
> <node id="n37">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">38</data>
> </node>
> <node id="n38">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">39</data>
> </node>
> <node id="n39">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">40</data>
> </node>
> <node id="n40">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">41</data>
> </node>
> <node id="n41">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">42</data>
> </node>
> <node id="n42">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">43</data>
> </node>
> <node id="n43">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">44</data>
> </node>
> <node id="n44">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">45</data>
> </node>
> <node id="n45">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">46</data>
> </node>
> <node id="n46">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">47</data>
> </node>
> <node id="n47">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">48</data>
> </node>
> <node id="n48">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">49</data>
> </node>
> <node id="n49">
> <data key="creation">0</data>
> <data key="type">0</data>
> <data key="name">50</data>
> </node>
> <node id="n50">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">51</data>
> </node>
> <node id="n51">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">52</data>
> </node>
> <node id="n52">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">53</data>
> </node>
> <node id="n53">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">54</data>
> </node>
> <node id="n54">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">55</data>
> </node>
> <node id="n55">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">56</data>
> </node>
> <node id="n56">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">57</data>
> </node>
> <node id="n57">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">58</data>
> </node>
> <node id="n58">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">59</data>
> </node>
> <node id="n59">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">60</data>
> </node>
> <node id="n60">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">61</data>
> </node>
> <node id="n61">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">62</data>
> </node>
> <node id="n62">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">63</data>
> </node>
> <node id="n63">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">64</data>
> </node>
> <node id="n64">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">65</data>
> </node>
> <node id="n65">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">66</data>
> </node>
> <node id="n66">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">67</data>
> </node>
> <node id="n67">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">68</data>
> </node>
> <node id="n68">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">69</data>
> </node>
> <node id="n69">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">70</data>
> </node>
> <node id="n70">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">71</data>
> </node>
> <node id="n71">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">72</data>
> </node>
> <node id="n72">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">73</data>
> </node>
> <node id="n73">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">74</data>
> </node>
> <node id="n74">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">75</data>
> </node>
> <node id="n75">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">76</data>
> </node>
> <node id="n76">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">77</data>
> </node>
> <node id="n77">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">78</data>
> </node>
> <node id="n78">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">79</data>
> </node>
> <node id="n79">
> <data key="creation">0</data>
> <data key="type">1</data>
> <data key="name">80</data>
> </node>
> <edge source="n11" target="n50">
> <data key="creation">0</data>
> </edge>
> <edge source="n38" target="n57">
> <data key="creation">0</data>
> </edge>
> <edge source="n21" target="n79">
> <data key="creation">0</data>
> </edge>
> <edge source="n13" target="n59">
> <data key="creation">0</data>
> </edge>
> <edge source="n8" target="n59">
> <data key="creation">0</data>
> </edge>
> <edge source="n32" target="n59">
> <data key="creation">0</data>
> </edge>
> <edge source="n26" target="n73">
> <data key="creation">0</data>
> </edge>
> <edge source="n18" target="n69">
> <data key="creation">0</data>
> </edge>
> <edge source="n28" target="n59">
> <data key="creation">0</data>
> </edge>
> <edge source="n30" target="n78">
> <data key="creation">0</data>
> </edge>
> <edge source="n12" target="n51">
> <data key="creation">0</data>
> </edge>
> <edge source="n29" target="n52">
> <data key="creation">0</data>
> </edge>
> <edge source="n34" target="n65">
> <data key="creation">0</data>
> </edge>
> <edge source="n7" target="n54">
> <data key="creation">0</data>
> </edge>
> <edge source="n41" target="n61">
> <data key="creation">0</data>
> </edge>
> <edge source="n46" target="n74">
> <data key="creation">0</data>
> </edge>
> <edge source="n22" target="n58">
> <data key="creation">0</data>
> </edge>
> <edge source="n16" target="n58">
> <data key="creation">0</data>
> </edge>
> <edge source="n15" target="n70">
> <data key="creation">0</data>
> </edge>
> <edge source="n23" target="n76">
> <data key="creation">0</data>
> </edge>
> <edge source="n1" target="n56">
> <data key="creation">0</data>
> </edge>
> <edge source="n49" target="n65">
> <data key="creation">0</data>
> </edge>
> <edge source="n44" target="n57">
> <data key="creation">0</data>
> </edge>
> <edge source="n5" target="n69">
> <data key="creation">0</data>
> </edge>
> <edge source="n36" target="n51">
> <data key="creation">0</data>
> </edge>
> <edge source="n35" target="n61">
> <data key="creation">0</data>
> </edge>
> <edge source="n20" target="n66">
> <data key="creation">0</data>
> </edge>
> <edge source="n14" target="n62">
> <data key="creation">0</data>
> </edge>
> <edge source="n27" target="n73">
> <data key="creation">0</data>
> </edge>
> <edge source="n25" target="n75">
> <data key="creation">0</data>
> </edge>
> </graph>
> </graphml>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>