Пример #1
0
    def __init__(self, N = 10000, m_0 = 3):
        """
        :Purpose:
          This is the base class used to generate the social network 
          and neighborhoods. The class inherits from the PopulationClass.

        :Input:	
            N : int
              Number of agents. Default: 10000
            m_0: int	
              Number of nodes each node is connected to in preferential
              attachment step
        """
        if type(N) is not int:			
            raise ValueError(('Population size must be integer,\
					n = %s, not %s')%(string(N), type(N)))	
        else: pass
        if m_0 not in range(10):
            raise ValueError('m_0 must be integer smaller than 10')
        else: self.m_0 = m_0

        PopulationClass.__init__(self, n = N)	# Create population
        self.repeated_nodes = {'All':[], 'IDU':[], 'NIDU':[], 'ND':[], 'HIV':[]}
        self.G = nx.Graph()
        self._set_assortative_graph()		# create graph
Пример #2
0
    def __init__(self, N = 10000, m_0 = 3):
        """
        :Purpose:
            This is the base class used to generate the social network 
            for the other agents, i.e. . The class inherits from the PopulationClass.

        :Input:	
            N : int
              Number of agents. Default: 10000

            m_0: int	
              Number of nodes each node is connected to in preferential
              attachment step
        """
        if type(N) is not int:			
            raise ValueError(('Population size must be integer,\
                                      n = %s, not %s')%(string(N), type(N)))	
        else: pass
        if m_0 not in range(10):
            raise ValueError('m_0 must be integer smaller than 10')
        else: self.m_0 = m_0

        PopulationClass.__init__(self, n = N)	# Create population
        SpecialAgents = set(self.IDU_agents).union(set(self.MSM_agents))
        SpecialAgents = SpecialAgents.union(set(self.NIDU_agents))
        NormalAgents = set(range(self.PopulationSize)).difference(SpecialAgents)
        NormalAgents = list(NormalAgents)
        self.NetworkSize = len(NormalAgents)
        # scale free Albert Barabsai Graph
        self.G = nx.barabasi_albert_graph(self.NetworkSize,m_0)