<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_demand_graph(self):
 """create demand graph"""

        # The number of clusters
        K = self.origins.shape[0]

        # Set the number of accounts in each cluster to be the same
        # as for the nearest neighbor solution
        demand = self.nearest_targets.groupby('origin_id')['geometry'].count().to_dict()

        # Set up the graph so we can extract and initialize the node labels.
        # For each iteration, we're going to sort all our data by their origin
        # label assignments in order to properly index our nodes.
        self.targets = self.targets.sort_values('labels').reset_index(drop=True)

        # Add target nodes
        g = nx.DiGraph()
        g.add_nodes_from(self.targets['target_id'], demand=-1)

        # Add origin nodes
        for idx in demand:
            g.add_node(int(idx), demand=demand[idx])

        # Dictionary of labels (corresponding to the sales rep) for
        # each med center node.
        dict_M = {
            i: (
                self.targets[self.targets['target_id'] == i]['labels'].values
                if i in self.targets.target_id.values
                else np.array([demand[i]])
            )
            for i in g.nodes
        }
        logging.info('Graph and demand dictionary created')
        return dict_M, demand