14、分层聚类:结构化区域与非结构化区域

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了14、分层聚类:结构化区域与非结构化区域相关的知识,希望对你有一定的参考价值。

参考技术A 14、分层聚类:结构化区域与非结构化区域

import time as time

import numpy as np

import matplotlib.pyplot as plt

import mpl_toolkits.mplot3d.axes3d as p3

from sklearn.cluster import AgglomerativeClustering

from sklearn.datasets import make_swiss_roll

plt.rcParams['font.sans-serif'] = ['SimHei']

plt.rcParams['axes.unicode_minus'] = False

# 生成数据(瑞士轧辊数据集)

n_samples = 1500

noise = 0.05

X, _ = make_swiss_roll(n_samples, noise=noise)

# 使它变薄

X[:, 1] *= .5

# 计算聚类

print("Compute unstructured hierarchical clustering...")

st = time.time()

ward = AgglomerativeClustering(n_clusters=6, linkage='ward').fit(X)

elapsed_time = time.time() - st

label = ward.labels_

print("Elapsed time: %.2fs" % elapsed_time)

print("Number of points: %i" % label.size)

# 绘图结果

fig = plt.figure()

ax = p3.Axes3D(fig)

ax.view_init(7, -80)

for l in np.unique(label):

    ax.scatter(X[label == l, 0], X[label == l, 1], X[label == l, 2],

              color=plt.cm.jet(np.float(l) / np.max(label + 1)),

              s=20, edgecolor='k')

plt.title('无连通性约束(time %.2fs)' % elapsed_time)

# 定义数据的结构A。这里有10个最近的邻居

from sklearn.neighbors import kneighbors_graph

connectivity = kneighbors_graph(X, n_neighbors=10, include_self=False)

# 计算聚类

print("Compute structured hierarchical clustering...")

st = time.time()

ward = AgglomerativeClustering(n_clusters=6, connectivity=connectivity,

                              linkage='ward').fit(X)

elapsed_time = time.time() - st

label = ward.labels_

print("Elapsed time: %.2fs" % elapsed_time)

print("Number of points: %i" % label.size)

#  绘图结果

fig = plt.figure()

ax = p3.Axes3D(fig)

ax.view_init(7, -80)

for l in np.unique(label):

    ax.scatter(X[label == l, 0], X[label == l, 1], X[label == l, 2],

              color=plt.cm.jet(float(l) / np.max(label + 1)),

              s=20, edgecolor='k')

plt.title('具有连通性约束 (time %.2fs)' % elapsed_time)

plt.show()

OSPF协议 配置和实验明文验证密文验证。

OSPF协议:
1、链路状态型的路由协议
特点:所有路由器上对全网的拓扑都了解,即每台路由器收到的信息不只是邻居,通过不同(1、2、3、4、5、7)类型的LSA(链路状态通告)去感知全网的网络
2、OSPF的算法是SPF的算法,树型结构算法无环路
3、分层区域(骨干区域area 0和非骨干区域area 1等)。分层原则:所有的非骨干区域必须连接在骨干区域上。Ospf的区域是基于接口划分的。
#router ospf 100==将OSPF定义为IP路由协议,100位进程号,本地有效
#router-id 2.2.2.2(2.2.2.2每个网络里都是唯一的,感知网络就是通过router ID来标示每个路由器.
技术图片

按拓扑图运行OSPF、 要求全网能通PC1能通PC2、 R1上看到去R4的两条等价负载均衡。
R1 traceroute R4 R4-R3-R1
R4>enable
configure terminal
interface fa 0/0
no shutdown
ip address 44.1.1.1 255.0.0.0
interface se 3/0
no shutdown
ip address 24.1.1.4 255.0.0.0
interface fa 1/0
no shutdown
ip address 34.1.1.4 255.0.0.0
router ospf 100 将ospf定义为IP路由协议,进程号为100 (进程号必须大家一致)
router-id 4.4.4.4 感知网络就是通过router ID来标示每个路由器,同个网络必须都是唯一的
network 44.1.1.0 0.0.0.255 area 0 定义44.1.1.0网段IP 为骨干区域area 0
network 24.1.1.0 0.0.0.255 area 0
network 34.1.1.0 0.0.0.255 area 0
技术图片

R3>enable
configure terminal
interface fa 1/0
no shutdown
ip address 34.1.1.3 255.0.0.0
interface fa 0/0
no shutdown
ip address 192.168.10.3 255.255.255.0
router ospf 100
router-id 3.3.3.3
network 34.1.1.0 0.0.0.255 area 0定义34.1.1.0网段IP 为骨干区域area 0
network 192.168.10.0 0.255.255.255 area 1定义192.168.10.0网段IP 为非骨干区域area 1
R2配置同上。IP为:192.168.10.2 24.1.1.2
技术图片

R1>
eanble
configure terminal
interface fa 0/0
no shutdown
ip address 192.168.10.1 255.255.255.0
interface fa 1/0
no shutdown
ip address 11.1.1.1 255.0.0.0
router ospf 100
router-id 1.1.1.1
network 192.168.10.0 0.255.255.255
network 11.1.1.0 0.0.0.255
show ip route
技术图片技术图片
验证是在端口上生效,必须路由器与路由器连接的端口配置密码一样。否则就不能访问。
明文验证:
#int s1/0
#ip ospf authenticarion-key xxwj 设置验证密码启秘钥,必须保持一致
#exit
#router ospf 1
#area 1 authentication 开启验证
密文验证:
#int s1/0
#ip ospf message-digest-key 1 md5 ccie
#area 0 authentication messate-digest

备注:实际中会发现环回口无法与网络正常连接,是因为子网掩码不一样,OSPF 路由器将环回口的网络类型认为是一种特殊的类型, LOOPBACK 类型。因此不管环回口前缀长度为多少,都一致认为其长度为 32。
因此,只需要更改环回口的网络类型即可。通常更改为点到点网络类型即可。这样环回口的子网又变回24了。
R1(config)#int lo0
R1(config-if)#ip ospf network point-to-point

以上是关于14、分层聚类:结构化区域与非结构化区域的主要内容,如果未能解决你的问题,请参考以下文章

OSPF多区域配置;骨干区域与非骨干区域;ABR边界路由器;LSA和SPF算法

Excel催化剂开源第14波-VSTO开发之单元格区域转DataTable

DBSCAN 算法

Python图像处理丨基于K-Means聚类的图像区域分割

Excel 区域表格化及结构化引用

GIS空间数据类型都有哪些?