• R/O
  • SSH

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

File Info

Rev. 70b9d97185740966fa69c1757c49aa1715d0e7dc
Tamanho 2,442 bytes
Hora 2009-08-08 00:25:06
Autor lorenzo
Mensagem de Log

CAVEAT: this code works only with the initial version of the library
by Ciro. However, it prints out the tag-tag contact list and the corresponding
time, i.e. everything I need to get the tag contact duration/interval

statistics.

Content

#!/usr/bin/env python
# loop over 20-second intervals, compute contact graph for each interval, print out the nodes of the graph

import sys
from sociopatterns.loader import Loader
from sociopatterns.analysis import ContactGraphAnalyzer
#import string #Probably I do not need this module any longer.
#Python has a lot of methods already inbuilt for a string object.


#XXTEA_CRYPTO_KEY = ( 0xf6e103d4, 0x77a739f6, 0x65eecead, 0xa40543a9 )

XXTEA_CRYPTO_KEY = ( 0xd2e3fd73, 0xfa70ca9c, 0xe2575826, 0x0fe09946 )


loader = Loader(sys.argv[1:], decode=1, xxtea_crypto_key=XXTEA_CRYPTO_KEY,
                load_contacts=1, unique_contacts=1, load_sightings=0)

analyzer = ContactGraphAnalyzer(loader, 20, tag_id_min=1100, tag_id_max=2047)

for frame in analyzer:

    #Thanks Corrado!

    #I changed into a comment a lot of lines which are no longer needed.
  
    # my_nodes=frame['graph'].nodes()
    # my_nodes_list=["%d" %x for x in frame['graph'].nodes()]
    # my_nodes_string=" ".join(my_nodes_list) 

    # #The same result is achieved with the suggestion by Ciro

    # #string.join(map(str, my_nodes)) ## to be  used within a print statement
    
    # my_edge_list_ini=["%d %d" %(x, y)  for x,y, in frame['graph'].edges() ]

    # my_edge_string=" ".join(my_edge_list_ini)

    # my_edge_string_vert="\n".join(my_edge_list_ini) #prints out the edge list in the form of a binary tag-tag interaction


    
    
    # time_list_ini=[frame['time']]*len(frame['graph'].edges())
    # time_list_ini=["%d" %x for x in time_list_ini]
    # time_string=" ".join(time_list_ini)
    # time_string_vert="\n".join(time_list_ini) #prints out time as a vertical string


    # # total=["%d %d %d" %(x[0], x[1], z)  for x,z in zip(frame['graph'].edges(),[frame['time']]*len(frame['graph'].edges()) ) ]
    # # total="\n".join(total)

    #Suggestion by Corrado. "\n" is a string and its .join method automatically adds another string to it.
    #the object within [] is a list of strings from which I extract a triplet of integers. 
 
    total="\n".join(["%d %d %d" %( frame["time"],x, y)  for x,y in frame['graph'].edges()])


  
    # time_and_edges_vert="\n".join(time_and_edges)
    
    
    #old layout I had chosen for my printout
    #use -1 as a separator

    #print  frame['time'], -1, my_edge_list , -1,frame['graph'].number_of_nodes(),-1, my_nodes_list


    
    if (len(frame['graph'].edges())>0):

        print total