def get_agents(self, state_id=None, limit_neighbors=False):
if limit_neighbors:<EOL><INDENT>agents = self.global_topology.neighbors(self.id)<EOL><DEDENT>else:<EOL><INDENT>agents = self.get_all_nodes()<EOL><DEDENT>if state_id is None:<EOL><INDENT>return [self.global_topology.node[_]['<STR_LIT>'] for _ in agents]  <EOL><DEDENT>else:<EOL><INDENT>return [self.global_topology.node[_]['<STR_LIT>'] for _ in agents<EOL>if self.global_topology.node[_]['<STR_LIT>'].state['<STR_LIT:id>'] == state_id]<EOL><DEDENT>
Returns list of agents based on their state and connectedness

        Parameters
        ----------
        state_id : int, str, or array-like, optional
            Used to select agents that have the same specified "state". If state = None, returns all agents regardless
            of its current state
        limit_neighbors : bool, optional
            Returns agents based on whether they are connected to this agent or not. If limit_neighbors = False,
            returns all agents whether or not it is directly connected to this agent