import random


def _random_subset(seq, m):
    """Taken from NetworkX
    Given a sequence seq, return a ransom subset of size m.

    Parameters
    ----------
    seq : list
        The population
    m : int
        The sample size

    Returns
    -------
    set
        The sample from seq of size m
    """
    #    Copyright (C) 2004-2016 by
    #    Aric Hagberg <hagberg@lanl.gov>
    #    Dan Schult <dschult@colgate.edu>
    #    Pieter Swart <swart@lanl.gov>
    #    All rights reserved.
    #    BSD license.
    targets = set()
    while len(targets) < m:
        x = random.choice(seq)
        targets.add(x)
    return targets