PHP Classes

File: examples/extras/science/maths/tmathgraphhandler/tmathgraphhandler.betweennesscentrality.php

Recommend this page to a friend!
  Packages of Christos Drogidis   Ascoos OS   examples/extras/science/maths/tmathgraphhandler/tmathgraphhandler.betweennesscentrality.php   Download  
File: examples/extras/science/maths/tmathgraphhandler/tmathgraphhandler.betweennesscentrality.php
Role: Example script
Content type: text/plain
Description: This example computes the betweenness centrality of all vertices in a small undirected graph.
Class: Ascoos OS
A PHP Web 5.0 Kernel for decentralized web and IoT
Author: By
Last change:
Date: 1 month ago
Size: 2,262 bytes
 

Contents

Class file image Download
<?php
/*
dobu {
    file:id(`example-00002108`) {
        ascoos {
            logo {`
                  __ _ ___ ___ ___ ___ ___ ___ ___
                 / _' |/ / / __/ _ \ / _ \ / / / _ \ / /
                | (_| |\ \| (_| (_) | (_) |\ \ | (_) |\ \
                 \__,_|/__/ \___\___/ \___/ /__/ \___/ /__/
            `},
            name {`ASCOOS OS`},
            version {`1.0.0`}
        },
        example {
            class {`TMathGraphHandler`},
            methods {`betweennessCentrality()`},
            source {`extras/science/maths/tmathgraphhandler/tmathgraphhandler.betweennesscentrality.php`},
            category:langs {
                en {`Graph Mathematics`},
                el {`?????????? ??????????`}
            },
            subcategory:langs {
                en {`Graph Centrality`},
                el {`???????????? ??????`}
            },
            summary:langs {
                en {`Demonstrates computation of betweenness centrality.`},
                el {`??????? ??? ?????????? ??? ????????????? ?????????.`}
            },
            desc:langs {
                en {`This example computes the betweenness centrality of all vertices in a small undirected graph.`},
                el {`?? ?????????? ?????????? ??? ???????????? ????????? ???? ??? ??????? ?? ???? ????? ?? ????????????? ?????.`}
            },
            author {`Drogidis Christos`},
            since {`1.0.0`},
            sincePHP {`8.4.0`}
        }
    }
}
*/
declare(strict_types=1);

use
ASCOOS\OS\Kernel\Science\Maths\TMathGraphHandler;

$startTime = microtime(true);
$startMem = memory_get_usage();

$math = new TMathGraphHandler();

$graph = [
   
'A' => ['B','C'],
   
'B' => ['A','C','D'],
   
'C' => ['A','B'],
   
'D' => ['B']
];

echo
"<pre>";
echo
"=== betweennessCentrality() Example ===\n\n";

$C = $math->betweennessCentrality($graph);

echo
"Betweenness Centrality:\n";
print_r($C);

echo
"</pre>";

$math->Free();
print_stats($startTime, $startMem);
?>