$html .= '<span class="barrier">' . $text . '</span>';
                    } else {
                        if ($this->start->getCoord() == $coord) {
                            $html .= '<span class="start">' . $text . '</span>';
                        } else {
                            if ($this->end->getCoord() == $coord) {
                                $html .= '<span class="end">' . $text . '</span>';
                            } else {
                                if (in_array($coord, $path)) {
                                    //$target = $this->path[$coord];
                                    //$text = $target->getF() . '-' . $target->getG() . '-' . $target->getH();
                                    $html .= '<span class="path">' . $text . '</span>';
                                } else {
                                    $html .= '<span>' . $text . '</span>';
                                }
                            }
                        }
                    }
                }
                $html .= '</li>';
            }
            $html .= '</ul>';
        }
        return $html;
    }
}
$options = array('barrier' => array('2,5', '3,5', '4,5', '5,5', '6,5', '7,5', '8,5', '9,5'), 'start' => '5,3', 'end' => '5,9');
$graph = new Graph($options);
$graph->createMap();
$graph->find();
echo $graph->displayMap();
Example #2
0
<?php

require_once 'core/init.php';
$graph = new Graph();
$from = Input::get('from');
$to = Input::get('to');
$data = $graph->find($from, $to);
?>
    <input type="hidden" id="route" name="route" value="<?php 
echo $data['route'];
?>
" required>
    <br>
    <div class="input-group">
        <span class="input-group-addon" id="sizing-addon2">Разстояние (км.):</span>
        <input type="numebr" class="form-control" id="distance" name="distance" value="<?php 
echo $data['distance'];
?>
" aria-describedby="sizing-addon2" readonly required>
    </div>
    <hr>