R语言代做编程辅导ASSIGNMENT FOUR – RANDOM GRAPHS(附答案)

PROBLEM 1) Creating Random Adjacency Matrices

Script Name: adjMatrix Input: n… The number of vertices in the graph p… Probablity two vertices are connected plot

LE PHUONG撰写

whether or not the matrix should be plotted as a graph Output: The nxn matrix of zero and ones Error Checking: The dimension is postive (else return NULL)

×

现在提到了代写服务,肯定很多人都不会觉得陌生,就算是国内也是有着专业代写作业的服务行业的,能够为有需求的学生提供很多的帮助,不过其实代写机构在国外会更获得学生的支持,这是因为国外的学校对于平时的作业要求比较严格,为了获得更高的分数顺利毕业,不少留学生就会让代写机构帮忙完成作业,比较常见的作业代写类型,就是计算机专业了,因为对于留学生来说这个技术对于Machine Learning或者AI的代码编程要求更高,所以找代写机构完成作业会简单轻松很多,那么代写机构的水平,要怎么选择才会比较高?

1、代写机构正规专业

不论是在什么情况下,选择正规合法经营的机构肯定是首要的操作,这也是为了避免自己在找机构的时候,出现上当受骗的现象,造成自己的经济出现损失,带来的影响还是非常大的,所以需要注意很多细节才可以,所以在这样的情况下,代写机构的选择,也要选择在经营方面属于正规合法的类型,这样才可以保证服务进行的时候,不会出现各种问题,也可以减少损失的出现,而且正规合法也是代写机构的合格基础。

2、代写机构编程能力

作业的难度相信很多人都很熟悉,特别是对于AI深度学习或者是人工神经网络这种算法来说,因为要对SVM、Design Tree、线性回归以及编程有很高的要求,可以说作业的完成要求非常高,因此才会带动代写机构的发展,找专业的代写机构,一般都是会有专业的人员帮忙进行作业的完成,因为这类型的作业对专业要求比较高,因此代写机构也要具备专业能力才可以,否则很容易导致作业的完成出现问题,出现低分的评价。

3、代写机构收费情况

现在有非常多的留学生,都很在意作业的完成度,为了保证作业可以顺利的被完成,要进行的相关操作可是非常多的,代写机构也是因为如此才会延伸出来的,在现在发展也很迅速,现在选择代写机构的时候,一定要重视收费情况的合理性,因为代写作业还是比较费精力的,而且对于专业能力要求也高,所以价格方面一般会收取几千元至万元左右的价格,但是比较简单的也只需要几百元价格。

4、代写机构完成速度

大部分人都很在意代写机构的专业能力,也会很关心要具备什么能力,才可以展现出稳定的代写能力,其实专业的代写机构,对于作业完成度、作业完成时间、作业专业性等方面,都是要有一定的能力的,特别是在完成的时间上,一定要做到可以根据客户规定的时间内完成的操作,才可以作为合格专业的代写机构存在,大众在选择的时候,也可以重视完成时间这一点来。

现在找专业的CS代写机构帮忙完成作业的代写,完全不是奇怪的事情了,而且专业性越强的作业,需要代写机构帮忙的几率就会越高,代写就发展很好,需求量还是非常高的,这也可以很好的说明了,这个专业的难度以及专业性要求,才可以增加代写机构的存在。



Description: The matrix is related to a simple, undirected graph of n vertices. In the graph is Vertex i and Vectex j are joined by an edge,

then in the matrix A[i,j] = 1, if no edge exists then A[i,j]=0. There are differenct ways of handling the diagonal. We will require the diagonal elements to be NA.

The matrix must be symmetric. That is A[i,j]=A[j,1]

Whether or not an entry in the matrix is 0 or 1, is determined by drawing numbers from the binomial distribution. This distribution will yield a 1 with probability p and a o with probability (1-p). In R it will work like this, in the ith column (vertex i) , we require A[i,i] to be NA. This leaves n-1 entries to be determined. We use the command rbinom(n-1,1,p) to general these entries all at once, or rbinom(1,1,p) to generate them one at a time.

Plot: Using igraph create a simple plot. Use a color easy on the eyes such as something found in the Brewer color palette (discussed in class)


requires(igraph)

adjMatrix<-function(n,p,plot=FALSE)
{m=matrix(1,n,n)
  for(i in 1:n){
    for(j in 1:n){
      if(i<j){
        
        m[i,j]=ifelse(i==j,NA,rbinom(1,1,p) )
        m[j,i]=m[i,j]
      }
    }
  }
  colpal<-brewer.pal(8,"Dark2")  
  
  gA <- graph.adjacency(m, mode="undirected",diag=FALSE )
  V(gA)$color<-colpal[1]   You choose 1 to 8... try some others
  plot(gA, layout=layout.auto,main="Random Graph using Brewer Color Palette")
  s
}

PROBLEM 2) Person with the most friends in the network

Script Name: vowelMax Input: A… An adjacency matrix plot… Plot the graph with the “friends” network highlighted Output: The number of the vertex with the most edge connections Error Checking: None


python岭回归、Lasso、随机森林、XGBoost、Keras神经网络、kmeans聚类链家租房数据地理可视化分析

阅读文章


Description: The number of “friends” a person has in a network is the number of edges connected to that vertex. The ith person in the network, will be connected to the jth person if A[i,j]=1. So the number of 1’s in the ith column reports how many edges connect person i to others In mathematical terms, this is called the “degree” of vertex i.

So you must determine the number of ones in each column and then find which column has the most ones.


随时关注您喜欢的主题


Hint: There is a quick trick to use here. Since a column has only 0 or 1 in it, the sum of all of the numbers in the column is the same as the number of 1’s in the column. Prove that to yourself.

Plot: Use igraph to plot the graph. Use three colors for the vertices: one for the most friendly person, another for his/her immediate friends, and another for the remaining vertices. Color red the edges from the most friendly person to his/her friends. All remaining edges are black.

mostFriends<-function(A,plot=FALSE)
{
  A[is.na(A)]=0
  s=which(apply(A,2,sum)==max(apply(A,2,sum)))
  n=which(A[,s]==1)
  pastel<-brewer.pal(8,"Pastel2")   Try a different palette  	
  gA <- graph.adjacency(A, mode="undirected",diag=FALSE )
  V(gA)[n]$color<-pastel[1]
  V(gA)[s]$color<-pastel[2]   changes the 5 vertex to the 4th color of the palette
  V(gA)[n]$color<-pastel[3]
  E(gA)[s%--%n]$color<-"red"
  plot(gA, layout=layout.auto,main="Random Graph With A Range of Vertices Colored")
  s
}

PROBLEM 3) Find a lonely person

Script Name: noFriends Input: A… An adjacency matrix Output: The number of the vertex with the no edge connections Error Checking: None

Description: The number of “friends” a person has in a network is the number of edges connected to that vertex. The ith person in the network, will be connected to the jth person if A[i,j]=1. So the number of 1’s in the ith column reports how many edges connect person i to others In mathematical terms, this is called the “degree” of vertex i.

So you must determine the number of ones in each column and then find which column has the most ones.

Hint: There is a quick trick to use here. Since a column has only 0 or 1 in it, the sum of all of the numbers in the column is the same as the number of 1’s in the column. Prove that to yourself.

Plot: Create a plot of the graph using igraph. Make the “lonely” person/people a different color

noFriends<-function(A,plot=FALSE)
{
   s=which(apply(A,2,sum)==0))

PROBLEM 4) Number of friendship relationships in the network

Script Name: numFriendships Input: A… An adjacency matrix Output: The number of uniqe edges in the graph

Description: The number of friendships in the network is the number of edges in the graph. Basically, count the ones in the adjacency matrix, but be careful. (Remember, an edge from i to j is the same as an edge from j to i)

numFriendships<-function(A)
{

num
}

PROBLEM 5) Add a person to the friendship network

Script Name: addPerson Input: A… An adjacency matrix p… Probability a relationship forms plot… Show the new person and relationships Output: New adjacency matrix

Description: As in creating an adjacency matrix, a new column is added and the binomail distribution is used to determine the 1 entries.

Plot: Plot the graph using igraph. Use three colors for the vertices: one for the newly added person, another for his/her immediate friends, and another for the remaining vertices. Color red the edges from the new person to his/her friends. All remaining edges are black.

addPerson<-function(A,p,plot)
{
	
 n=nrow(A)
  new=rep(1,n)
  for(i in 1:n){
    new[i]=rbinom(1,1,p)
  }
  A=cbind(A,new)

PROBLEM 6) Add several people to the friendship network

Script Name: growNetwork Input: A… An adjacency matrix p… Probability a relationship forms n… the number of people to add plot… Show the new person and relationships Output: New adjacency matrix

Plot: Plot the graph using igraph. Use three colors for the vertices: one for the newly added person, another for his/her immediate friends, and another for the remaining vertices. Color red the edges from the new person to his/her friends. All remaining edges are black.


growNetwork<-function(A,n,p,plot=FALSE)
{row=nrow(A)
  for(ii in 1:n){
    nn=nrow(A)
    new=rep(1,nn)
  for(i in 1:nn){
    new[i]=rbinom(1,1,p)
  }

关于分析师

在此对LE PHUONG对本文所作的贡献表示诚挚感谢,她在山东大学完成了计算机科学与技术专业的硕士学位,专注数据分析、数据可视化、数据采集等。擅长Python、SQL、C/C++、HTML、CSS、VSCode、Linux、Jupyter Notebook。

 
QQ在线咨询
售前咨询热线
15121130882
售后咨询热线
0571-63341498

关注有关新文章的微信公众号


永远不要错过任何见解。当新文章发表时,我们会通过微信公众号向您推送。

技术干货

最新洞察

This will close in 0 seconds