Exemplo n.º 1
0
$filename = get_filename_for_export("interactionGraph", "min" . $esc['shell']['minf'] . "nodes", "gexf");
$gexf = new Gexf();
$gexf->setTitle("interaction graph " . $filename);
$gexf->setEdgeType(GEXF_EDGE_DIRECTED);
$gexf->setCreator("tools.digitalmethods.net");
// label: user, attribute: tweet
// min, max, mean of what?? ditributions of nr of nodes in the network
foreach ($links as $link) {
    $tweet_id = $link[0];
    $in_reply_to_status_id = $link[1];
    if (array_search($in_reply_to_status_id, $todo) === false && array_search($tweet_id, $todo) === false) {
        continue;
    }
    $node1 = new GexfNode($in_reply_to_status_id);
    // if node already exists, we want the attributes added that node instead
    $id = $gexf->nodeExists($node1);
    if ($id !== false && isset($gexf->nodeObjects[$id])) {
        $node1 = $gexf->nodeObjects[$id];
    }
    $node1->addNodeAttribute('tweet_id', $in_reply_to_status_id, 'string');
    if (!isset($tweets[$in_reply_to_status_id])) {
        $tweet = getTweet($in_reply_to_status_id);
        if ($tweet !== false) {
            $node1->addNodeAttribute('created_at', $tweet['created_at'], 'string');
            $node1->addNodeAttribute('tweet', $tweet['text'], 'string');
            $node1->addNodeAttribute('user', $tweet['from_user_name'], 'string');
            $node1->addNodeAttribute('from_user_lang', $tweet['from_user_lang'], 'string');
            $node1->addNodeAttribute('from_user_tweetcount', $tweet['from_user_tweetcount'], 'integer');
            $node1->addNodeAttribute('from_user_followercount', $tweet['from_user_followercount'], 'integer');
            $node1->addNodeAttribute('from_user_friendcount', $tweet['from_user_friendcount'], 'integer');
            $node1->addNodeAttribute('from_user_listed', $tweet['from_user_listed'], 'integer');